From: Karel Zak Date: Tue, 9 Jun 2020 09:31:42 +0000 (+0200) Subject: logindefs: use xalloc.h, code cleanup X-Git-Tag: v2.36-rc1~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=19a353947dd16a78ca102ac002320b80ad3951e8;p=thirdparty%2Futil-linux.git logindefs: use xalloc.h, code cleanup - remove else-after-return - use else-if - use xalloc stuff Signed-off-by: Karel Zak --- diff --git a/login-utils/logindefs.c b/login-utils/logindefs.c index 3448e1fb1d..db89b93d54 100644 --- a/login-utils/logindefs.c +++ b/login-utils/logindefs.c @@ -279,8 +279,8 @@ void logindefs_load_file(const char *filename) logindefs_loader = NULL; /* No recursion */ #if USE_VENDORDIR - if (asprintf (&path, _PATH_VENDORDIR"/%s", filename) == -1) - return; + xasprintf(&path, _PATH_VENDORDIR"/%s", filename); + if (!econf_readFile(&file_l, path, "= \t", "#")) { if (file == NULL) file = file_l; @@ -293,8 +293,8 @@ void logindefs_load_file(const char *filename) free (path); #endif - if (asprintf (&path, "/etc/%s", filename) == -1) - return; + xasprintf(&path, "/etc/%s", filename); + if (!econf_readFile(&file_l, path, "= \t", "#")) { if (file == NULL) file = file_l; @@ -303,16 +303,15 @@ void logindefs_load_file(const char *filename) file = file_m; econf_free(file_l); } - } else { - /* Try original filename, could be relative */ - if (!econf_readFile(&file_l, filename, "= \t", "#")) { - if (file == NULL) - file = file_l; - else if (!econf_mergeFiles(&file_m, file, file_l)) { - econf_free(file); - file = file_m; - econf_free(file_l); - } + + /* Try original filename, could be relative */ + } else if (!econf_readFile(&file_l, filename, "= \t", "#")) { + if (file == NULL) + file = file_l; + else if (!econf_mergeFiles(&file_m, file, file_l)) { + econf_free(file); + file = file_m; + econf_free(file_l); } } free (path); @@ -383,8 +382,8 @@ const char *getlogindefs_str(const char *name, const char *dflt) } if (value) return value; - else - return strdup(""); + + return xstrdup(""); } #endif /* !HAVE_LIBECONF */