nwrap: better error propagation in nwrap_add_hname()
authorMichael Adam <obnox@samba.org>
Wed, 11 Nov 2015 11:28:58 +0000 (12:28 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 11 Jan 2016 11:25:30 +0000 (12:25 +0100)
Use return codes from called functions.
Remove now unneeded asserts.
Make failure to add an entry for an alias an error.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/nss_wrapper/nss_wrapper.c

index 343bff75cf7ee89c802eb8bca01699f4c87bd00c..9ed11f0c86cadc95b85c2058c9178465ef5af157 100644 (file)
@@ -2686,9 +2686,7 @@ static bool nwrap_add_hname(struct nwrap_entdata *const ed)
        ENTRY e;
        ENTRY *p;
        unsigned i;
-
-       assert(ed != NULL);
-       assert(h_name != NULL);
+       bool ok;
 
        e.key = h_name;
        e.data = NULL;
@@ -2696,13 +2694,16 @@ static bool nwrap_add_hname(struct nwrap_entdata *const ed)
        p = hsearch(e, FIND);
        if (p == NULL) {
                NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s not found. Adding...", h_name);
-               nwrap_add_hname_add_new(h_name, ed);
+               ok = nwrap_add_hname_add_new(h_name, ed);
        } else {
                struct nwrap_entlist *el = (struct nwrap_entlist *)p->data;
 
-               assert(p->data != NULL);
                NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s found. Add record to list.", h_name);
-               nwrap_add_hname_add_to_existing(ed, el);
+               ok = nwrap_add_hname_add_to_existing(ed, el);
+       }
+
+       if (!ok) {
+               return false;
        }
 
        if (ed->ht.h_aliases == NULL) {
@@ -2714,13 +2715,13 @@ static bool nwrap_add_hname(struct nwrap_entdata *const ed)
                char *h_name_alias;
 
                h_name_alias = ed->ht.h_aliases[i];
-               assert(h_name_alias != NULL);
 
                NWRAP_LOG(NWRAP_LOG_DEBUG, "Add alias: %s", h_name_alias);
 
                if (!nwrap_add_hname_alias(h_name_alias, ed)) {
                        NWRAP_LOG(NWRAP_LOG_DEBUG,
                                  "Unable to add alias: %s", h_name_alias);
+                       return false;
                }
        }