]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
pipe-filter-ii: Avoid some 'goto' statements.
authorBruno Haible <bruno@clisp.org>
Tue, 9 Dec 2025 22:47:56 +0000 (23:47 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 9 Dec 2025 22:47:56 +0000 (23:47 +0100)
* lib/pipe-filter-ii.c (_beginthreadex, WaitForMultipleObjects)
[__KLIBC__]: Avoid 'goto'.

ChangeLog
lib/pipe-filter-ii.c

index 59aa2c28ce457fa7f3da93bd7e0febf3897d42c3..2a9fa9aaa997f7c5b38dd8c88edf97ef48322459 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-12-09  Bruno Haible  <bruno@clisp.org>
+
+       pipe-filter-ii: Avoid some 'goto' statements.
+       * lib/pipe-filter-ii.c (_beginthreadex, WaitForMultipleObjects)
+       [__KLIBC__]: Avoid 'goto'.
+
 2025-12-09  Bruno Haible  <bruno@clisp.org>
 
        ssfmalloc: Simplify.
index c4fda29feffff26b9cb96d3754cb29de6e9ef1b9..1131265009f5a4d6b8e6d14bea24e39a754fbeea 100644 (file)
@@ -66,22 +66,17 @@ _beginthreadex (void *s, unsigned n, unsigned int WINAPI (*start) (void *),
   if (!h)
     return NULL;
 
-  if (DosCreateEventSem (NULL, &h->hevDone, 0, FALSE))
-    goto exit_free;
-
-  h->start = start;
-  h->arg = arg;
-
-  h->tid = _beginthread (start_wrapper, NULL, n, (void *) h);
-  if (h->tid == -1)
-    goto exit_close_event_sem;
+  if (! DosCreateEventSem (NULL, &h->hevDone, 0, FALSE))
+    {
+      h->start = start;
+      h->arg = arg;
 
-  return h;
+      h->tid = _beginthread (start_wrapper, NULL, n, (void *) h);
+      if (h->tid != -1)
+        return h;
 
- exit_close_event_sem:
-  DosCloseEventSem (h->hevDone);
-
- exit_free:
+      DosCloseEventSem (h->hevDone);
+    }
   free (h);
 
   return NULL;
@@ -123,7 +118,7 @@ WaitForMultipleObjects (DWORD nCount, const HANDLE *pHandles, BOOL bWaitAll,
 
   psr = malloc (sizeof (*psr) * nCount);
   if (!psr)
-    goto exit_return;
+    return (DWORD) -1;
 
   for (DWORD i = 0; i < nCount; ++i)
     {
@@ -131,21 +126,16 @@ WaitForMultipleObjects (DWORD nCount, const HANDLE *pHandles, BOOL bWaitAll,
       psr[i].ulUser  = WAIT_OBJECT_0 + i;
     }
 
-  if (DosCreateMuxWaitSem (NULL, &hmux, nCount, psr,
-                           bWaitAll ? DCMW_WAIT_ALL : DCMW_WAIT_ANY))
-    goto exit_free;
-
-  rc = DosWaitMuxWaitSem (hmux, ms, &ulUser);
-  DosCloseMuxWaitSem (hmux);
-
- exit_free:
+  if (DosCreateMuxWaitSem (NULL, &hmux, nCount, psr,
+                             bWaitAll ? DCMW_WAIT_ALL : DCMW_WAIT_ANY))
+    {
+      rc = DosWaitMuxWaitSem (hmux, ms, &ulUser);
+      DosCloseMuxWaitSem (hmux);
+      free (psr);
+      return rc ? (DWORD) -1 : ulUser;
+    }
   free (psr);
-
- exit_return:
-  if (rc)
-    return (DWORD) -1;
-
-  return ulUser;
+  return (DWORD) -1;
 }
 #else
 # include <signal.h>