nwrap: Some code cleanup for nwrap_load_module_fn()
authorAndreas Schneider <asn@samba.org>
Mon, 17 Feb 2020 10:56:38 +0000 (11:56 +0100)
committerAndreas Schneider <asn@samba.org>
Mon, 17 Feb 2020 10:56:38 +0000 (11:56 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
src/nss_wrapper.c

index 5c4c972819865c06b59d191da6ce625ec7eec517..3d9c3dc91ccce1700d80b64a5d8fef952b681390 100644 (file)
@@ -1471,21 +1471,23 @@ static int libc_getnameinfo(const struct sockaddr *sa,
 static void *nwrap_load_module_fn(struct nwrap_backend *b,
                                  const char *fn_name)
 {
-       void *res;
-       char *s;
+       void *res = NULL;
+       char *s = NULL;
+       int rc;
 
-       if (!b->so_handle) {
+       if (b->so_handle == NULL) {
                NWRAP_LOG(NWRAP_LOG_ERROR, "No handle");
                return NULL;
        }
 
-       if (asprintf(&s, "_nss_%s_%s", b->name, fn_name) == -1) {
+       rc = asprintf(&s, "_nss_%s_%s", b->name, fn_name);
+       if (rc == -1) {
                NWRAP_LOG(NWRAP_LOG_ERROR, "Out of memory");
                return NULL;
        }
 
        res = dlsym(b->so_handle, s);
-       if (!res) {
+       if (res == NULL) {
                NWRAP_LOG(NWRAP_LOG_ERROR,
                          "Cannot find function %s in %s",
                          s, b->so_path);