swrap: Fix the loop for older gcc versions.
authorAndreas Schneider <asn@samba.org>
Mon, 23 Feb 2015 16:15:12 +0000 (17:15 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 23 Feb 2015 19:02:51 +0000 (20:02 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
lib/socket_wrapper/socket_wrapper.c

index d5c343d024d5b35c9ab953f7ebdb241cebc73cf0..b30303f3192a7527699de02c3d83271e3e97e799 100644 (file)
@@ -452,11 +452,14 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
 #ifdef HAVE_LIBSOCKET
                handle = swrap.libsocket_handle;
                if (handle == NULL) {
-                       for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+                       for (i = 10; i >= 0; i--) {
                                char soname[256] = {0};
 
                                snprintf(soname, sizeof(soname), "libsocket.so.%d", i);
                                handle = dlopen(soname, flags);
+                               if (handle != NULL) {
+                                       break;
+                               }
                        }
 
                        swrap.libsocket_handle = handle;
@@ -474,11 +477,14 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
                }
 #endif
                if (handle == NULL) {
-                       for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+                       for (i = 10; i >= 0; i--) {
                                char soname[256] = {0};
 
                                snprintf(soname, sizeof(soname), "libc.so.%d", i);
                                handle = dlopen(soname, flags);
+                               if (handle != NULL) {
+                                       break;
+                               }
                        }
 
                        swrap.libc_handle = handle;