diff options
author | Andreas Schneider <asn@samba.org> | 2014-10-01 16:59:29 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2014-10-01 17:13:34 +0200 |
commit | 95c39b39f2f4529b9f59471fd3a99afdd57058ee (patch) | |
tree | 2ae3276d0a5b5629953a19d31739ad7f1122cc8f | |
parent | 163f08939567d5f837343ca6844c7121d6fe954e (diff) | |
download | socket_wrapper-95c39b39f2f4529b9f59471fd3a99afdd57058ee.tar.gz socket_wrapper-95c39b39f2f4529b9f59471fd3a99afdd57058ee.tar.xz socket_wrapper-95c39b39f2f4529b9f59471fd3a99afdd57058ee.zip |
swrap: Fix the loop for older gcc versions.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r-- | src/socket_wrapper.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index d5c343d..b30303f 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -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; |