]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Use streq() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Mon, 2 Dec 2024 12:16:56 +0000 (13:16 +0100)
committerSerge Hallyn <serge@hallyn.com>
Tue, 10 Dec 2024 02:54:42 +0000 (20:54 -0600)
Except for the added (and sorted) includes, the removal of redundant
parentheses, a few cases that have been refactored for readability, and
a couple of non-string cases that I've left out of the change, this
patch can be approximated with the following semantic patch:

$ cat ~/tmp/spatch/streq.sp
@@
expression s;
@@

- '\0' == *s
+ streq(s, "")

@@
expression s;
@@

- '\0' == s[0]
+ streq(s, "")

@@
expression s;
@@

- *s == '\0'
+ streq(s, "")

@@
expression s;
@@

- s[0] == '\0'
+ streq(s, "")

$ find contrib/ lib* src/ -type f \
| xargs spatch --in-place --sp-file ~/tmp/spatch/streq.sp;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
28 files changed:
lib/getdef.c
lib/getrange.c
lib/limits.c
lib/list.c
lib/port.c
lib/prefix_flag.c
lib/pwauth.c
lib/salt.c
lib/setupenv.c
lib/sgetgrent.c
lib/sgetpwent.c
lib/sgetspent.c
lib/sssd.c
lib/strtoday.c
lib/subordinateio.c
lib/utmp.c
lib/valid.c
src/grpck.c
src/login.c
src/login_nopam.c
src/newgrp.c
src/passwd.c
src/su.c
src/suauth.c
src/sulogin.c
src/useradd.c
src/userdel.c
src/usermod.c

index c59e8807fea34f9118a39455fd70f6dddbe389ad..d234fe18b0c1cff6062775dcd0493b5c4bfe62b3 100644 (file)
@@ -567,7 +567,7 @@ static void def_load (void)
                 * Break the line into two fields.
                 */
                name = stpspn(buf, " \t");      /* first nonwhite */
-               if (*name == '\0' || *name == '#')
+               if (streq(name, "") || *name == '#')
                        continue;       /* comment or empty */
 
                s = stpsep(name, " \t");  /* next field */
index 603152e68a660804a3668a0b10b447b79611eef3..44a055c7fd5c3e56f70709d51eb570f3a2065a80 100644 (file)
@@ -13,6 +13,7 @@
 #include "atoi/a2i/a2u.h"
 #include "defines.h"
 #include "prototypes.h"
+#include "string/strcmp/streq.h"
 
 
 /*
@@ -53,7 +54,7 @@ getrange(const char *range,
                return 0;  /* <long> */
 
        case '-':
-               if ('\0' == *end)
+               if (streq(end, ""))
                        return 0;  /* <long>- */
 parse_max:
                if (!isdigit((unsigned char) *end))
index 5a98a1295d1dda0d6a9146c25aa0343ac3c500b9..e1c3b179789921d9928277db5ae71076db30ca8a 100644 (file)
@@ -413,9 +413,9 @@ static int setup_user_limits (const char *uname)
                }
        }
        (void) fclose (fil);
-       if (limits[0] == '\0') {
+       if (streq(limits, "")) {
                /* no user specific limits */
-               if (deflimits[0] == '\0') {     /* no default limits */
+               if (streq(deflimits, "")) {     /* no default limits */
                        return 0;
                }
                strcpy (limits, deflimits);     /* use the default limits */
index a18c71862e4d4c9feea6c15170d2f620686f9a42..27aa02565998ea41f32a27cad4905ae3ceb172b7 100644 (file)
@@ -209,7 +209,7 @@ comma_to_list(const char *comma)
         * Empty list is special - 0 members, not 1 empty member.  --marekm
         */
 
-       if ('\0' == *members) {
+       if (streq(members, "")) {
                *array = NULL;
                free (members);
                return array;
index 52ed67e87884d38b7041cbcd5d2b43b5d554f9a7..4f5d06066a3fedb58c681ca4dae5f5837a471276 100644 (file)
@@ -44,7 +44,7 @@ static int portcmp (const char *pattern, const char *port)
                port++;
        }
 
-       if (('\0' == *pattern) && ('\0' == *port)) {
+       if (streq(pattern, "") && streq(port, "")) {
                return 0;
        }
        if (streq(orig, "SU"))
@@ -204,7 +204,7 @@ next:
 
        cp = field;
 
-       if ('\0' == *cp) {
+       if (streq(cp, "")) {
                port.pt_times = NULL;
                return &port;
        }
index ea0a0d7230283418fcbd0e3049c15ad9e65aaf09..c09b8d082633fc3851f3f3b45cc44c27acbe50d3 100644 (file)
@@ -98,7 +98,7 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
                        exit (EXIT_FAILURE);
                }
 
-               if (prefix[0] == '\0' || streq(prefix, "/"))
+               if (streq(prefix, "") || streq(prefix, "/"))
                        return ""; /* if prefix is "/" then we ignore the flag option */
                /* should we prevent symbolic link from being used as a prefix? */
 
index 0434dd08fd552a94fc1d470c211c5ed5ce684aaa..afdc2337a4fdbf48c3e04b84867569c87a660b5f 100644 (file)
@@ -26,6 +26,7 @@
 #include "getdef.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 
 #ifdef SKEY
 #include <skey.h>
@@ -102,7 +103,7 @@ int pw_auth (const char *cipher,
         * matter.
         */
 
-       if ((NULL == cipher) || ('\0' == *cipher)) {
+       if ((NULL == cipher) || streq(cipher, "")) {
                return 0;
        }
 
@@ -169,7 +170,7 @@ int pw_auth (const char *cipher,
         * ...Re-prompt, with echo on.
         * -- AR 8/22/1999
         */
-       if ((0 != retval) && ('\0' == input[0]) && use_skey) {
+       if ((0 != retval) && streq(input, "") && use_skey) {
                erase_pass(clear);
                clear = agetpass(prompt);
                input = (clear == NULL) ? "" : clear;
index f2432512ea27d1e6451b52fd45bab06d9ada9681..753e9d450760b96260b7114763c680ac4fe853e5 100644 (file)
@@ -419,7 +419,7 @@ static /*@observer@*/const char *gensalt (size_t salt_size)
         * Prepare DES setting for crypt_gensalt(), if result
         * has not been filled with anything previously.
         */
-       if ('\0' == result[0]) {
+       if (streq(result, "")) {
                /* Avoid -Wunused-but-set-variable. */
                salt_len = GENSALT_SETTING_SIZE - 1;
                rounds = 0;
index f49c6adefc8656e25550ddaa7d112d122c49d861..63f7fb95d1fd71e7f6e71ce06c3f614af84b7888 100644 (file)
@@ -28,6 +28,7 @@
 #include "shadowlog.h"
 #include "string/sprintf/xasprintf.h"
 #include "string/strchr/stpspn.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 #include "string/strtok/stpsep.h"
 
@@ -60,7 +61,7 @@ static void read_env_file (const char *filename)
                cp = buf;
                /* ignore whitespace and comments */
                cp = stpspn(cp, " \t");
-               if (('\0' == *cp) || ('#' == *cp)) {
+               if (streq(cp, "") || ('#' == *cp)) {
                        continue;
                }
                /*
@@ -209,7 +210,7 @@ void setup_env (struct passwd *info)
         * Create the SHELL environmental variable and export it.
         */
 
-       if ((NULL == info->pw_shell) || ('\0' == *info->pw_shell)) {
+       if ((NULL == info->pw_shell) || streq(info->pw_shell, "")) {
                free (info->pw_shell);
                info->pw_shell = xstrdup (SHELL);
        }
index 42b4efb7722f4bc2eccbc90449a3768ae36c0cdb..eeeed4b6f816e06327af62839e529ebd5abdc6fb 100644 (file)
@@ -21,6 +21,7 @@
 #include "atoi/getnum.h"
 #include "defines.h"
 #include "prototypes.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -54,7 +55,7 @@ list(char *s)
                                return NULL;
                        }
                }
-               if (!s || s[0] == '\0')
+               if (!s || streq(s, ""))
                        break;
                members[i++] = strsep(&s, ",");
        }
@@ -89,7 +90,7 @@ struct group *sgetgrent (const char *buf)
        for (cp = grpbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
                grpfields[i] = strsep(&cp, ":");
 
-       if (i < NFIELDS || *grpfields[2] == '\0' || cp != NULL) {
+       if (i < NFIELDS || streq(grpfields[2], "") || cp != NULL) {
                return NULL;
        }
        grent.gr_name = grpfields[0];
index 5704d19aeb51066902b0fb94e7a5eae89d9e4c5c..b13d5bc5465910d49b0932ec6a4bb409b9dc7124 100644 (file)
@@ -20,6 +20,7 @@
 #include "defines.h"
 #include "prototypes.h"
 #include "shadowlog_internal.h"
+#include "string/strcmp/streq.h"
 
 
 #define        NFIELDS 7
@@ -76,7 +77,11 @@ sgetpwent(const char *buf)
         * the entry is invalid.  Also, the UID and GID must be non-blank.
         */
 
-       if (i != NFIELDS || *fields[2] == '\0' || *fields[3] == '\0')
+       if (i != NFIELDS)
+               return NULL;
+       if (streq(fields[2], ""))
+               return NULL;
+       if (streq(fields[3], ""))
                return NULL;
 
        /*
index 97f64edd5ee80f9688e52b83fa1a9af2edd52489..f34853ec69eebb88eb767f2e92107a9241ea3b33 100644 (file)
@@ -24,6 +24,7 @@
 #include "defines.h"
 #include "prototypes.h"
 #include "shadowlog_internal.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -85,7 +86,7 @@ sgetspent(const char *string)
         * incorrectly formatted number.
         */
 
-       if (fields[2][0] == '\0')
+       if (streq(fields[2], ""))
                spwd.sp_lstchg = -1;
        else if (a2sl(&spwd.sp_lstchg, fields[2], NULL, 0, 0, LONG_MAX) == -1)
                return NULL;
@@ -94,7 +95,7 @@ sgetspent(const char *string)
         * Get the minimum period between password changes.
         */
 
-       if (fields[3][0] == '\0')
+       if (streq(fields[3], ""))
                spwd.sp_min = -1;
        else if (a2sl(&spwd.sp_min, fields[3], NULL, 0, 0, LONG_MAX) == -1)
                return NULL;
@@ -103,7 +104,7 @@ sgetspent(const char *string)
         * Get the maximum number of days a password is valid.
         */
 
-       if (fields[4][0] == '\0')
+       if (streq(fields[4], ""))
                spwd.sp_max = -1;
        else if (a2sl(&spwd.sp_max, fields[4], NULL, 0, 0, LONG_MAX) == -1)
                return NULL;
@@ -126,7 +127,7 @@ sgetspent(const char *string)
         * Get the number of days of password expiry warning.
         */
 
-       if (fields[5][0] == '\0')
+       if (streq(fields[5], ""))
                spwd.sp_warn = -1;
        else if (a2sl(&spwd.sp_warn, fields[5], NULL, 0, 0, LONG_MAX) == -1)
                return NULL;
@@ -136,7 +137,7 @@ sgetspent(const char *string)
         * disabled.
         */
 
-       if (fields[6][0] == '\0')
+       if (streq(fields[6], ""))
                spwd.sp_inact = -1;
        else if (a2sl(&spwd.sp_inact, fields[6], NULL, 0, 0, LONG_MAX) == -1)
                return NULL;
@@ -146,7 +147,7 @@ sgetspent(const char *string)
         * set to expire.
         */
 
-       if (fields[7][0] == '\0')
+       if (streq(fields[7], ""))
                spwd.sp_expire = -1;
        else if (a2sl(&spwd.sp_expire, fields[7], NULL, 0, 0, LONG_MAX) == -1)
                return NULL;
@@ -156,7 +157,7 @@ sgetspent(const char *string)
         * to have anything other than a valid integer in it.
         */
 
-       if (fields[8][0] == '\0')
+       if (streq(fields[8], ""))
                spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
        else if (str2ul(&spwd.sp_flag, fields[8]) == -1)
                return NULL;
index 09f539f46ca9020e029f98ff095b775526b3e35d..c795229a280cd4ba7c08426b9445fb78caa3c5c5 100644 (file)
@@ -1,7 +1,9 @@
 /* Author: Peter Vrabec <pvrabec@redhat.com> */
 
 #include <config.h>
+
 #ifdef USE_SSSD
+#include "sssd.h"
 
 #include <stdio.h>
 #include <sys/stat.h>
@@ -12,9 +14,8 @@
 #include "exitcodes.h"
 #include "defines.h"
 #include "prototypes.h"
-#include "sssd.h"
-
 #include "shadowlog_internal.h"
+#include "string/strcmp/streq.h"
 
 
 #define MSG_SSSD_FLUSH_CACHE_FAILED "%s: Failed to flush the sssd cache."
@@ -46,7 +47,7 @@ sssd_flush_cache(int dbflags)
        if (dbflags & SSSD_DB_GROUP)
                stpcpy(p, "G");
 
-       if (*p == '\0') {
+       if (streq(p, "")) {
                /* Neither passwd nor group, nothing to do */
                free(sss_cache_args);
                return 0;
index db0866097198a7e9a7025182619d0ac482aa5b96..056fa931e9cd77a7832b942d38e44b5648343b45 100644 (file)
 
 #include <ctype.h>
 
-#ident "$Id$"
-
 #include "atoi/str2i/str2s.h"
 #include "getdate.h"
 #include "prototypes.h"
 #include "string/strchr/stpspn.h"
+#include "string/strcmp/streq.h"
 
 
 /*
@@ -44,7 +43,7 @@ long strtoday (const char *str)
         * which is not what we expect, unless you're a BOFH :-).
         * (useradd sets sp_expire = current date for new lusers)
         */
-       if ((NULL == str) || ('\0' == *str)) {
+       if ((NULL == str) || streq(str, "")) {
                return -1;
        }
 
index 9329c455b3791deb51964c2a29a6a13a55bda998..bf02328e7977a79e2f6fa7c198ead93ffce3dbca 100644 (file)
@@ -108,7 +108,13 @@ subordinate_parse(const char *line)
         * There must be exactly SUBID_NFIELDS colon separated fields or
         * the entry is invalid.  Also, fields must be non-blank.
         */
-       if (i != SUBID_NFIELDS || *fields[0] == '\0' || *fields[1] == '\0' || *fields[2] == '\0')
+       if (i != SUBID_NFIELDS)
+               return NULL;
+       if (streq(fields[0], ""))
+               return NULL;
+       if (streq(fields[1], ""))
+               return NULL;
+       if (streq(fields[2], ""))
                return NULL;
        range.owner = fields[0];
        if (str2ul(&range.start, fields[1]) == -1)
index 37a1bbdae6e20c55a87b0b1d2d456bbcdccf8ceb..2b59dc6d9b6010deece47031840cc1597fff09b5 100644 (file)
@@ -53,13 +53,13 @@ is_my_tty(const char tty[UTX_LINESIZE])
                strcpy (full_tty, "/dev/");
        strncat(full_tty, tty, UTX_LINESIZE);
 
-       if ('\0' == tmptty[0]) {
+       if (streq(tmptty, "")) {
                const char *tname = ttyname (STDIN_FILENO);
                if (NULL != tname)
                        STRTCPY(tmptty, tname);
        }
 
-       if ('\0' == tmptty[0]) {
+       if (streq(tmptty, "")) {
                (void) puts (_("Unable to determine your tty name."));
                exit (EXIT_FAILURE);
        }
index d21afc5f70bfa8f926eaad79e41670579a5a97d3..a237e9e1fa4457195b475e817920b147e72c700c 100644 (file)
@@ -42,8 +42,8 @@ bool valid (const char *password, const struct passwd *ent)
         * routine is meant to waste CPU time.
         */
 
-       if ((NULL != ent->pw_name) && ('\0' == ent->pw_passwd[0])) {
-               if ('\0' == password[0]) {
+       if ((NULL != ent->pw_name) && streq(ent->pw_passwd, "")) {
+               if (streq(password, "")) {
                        return true;    /* user entered nothing */
                } else {
                        return false;   /* user entered something! */
@@ -54,7 +54,7 @@ bool valid (const char *password, const struct passwd *ent)
         * If there is no entry then we need a salt to use.
         */
 
-       if ((NULL == ent->pw_name) || ('\0' == ent->pw_passwd[0])) {
+       if ((NULL == ent->pw_name) || streq(ent->pw_passwd, "")) {
                salt = "xx";
        } else {
                salt = ent->pw_passwd;
index 405ae6c5e5014cd3b1464fd197457a1c5a880d1e..6bac2849f4167836da391c853b53ac87eb924bc5 100644 (file)
@@ -580,7 +580,8 @@ static void check_grp_file (int *errors, bool *changed)
                 */
                if (   (NULL != grp->gr_mem[0])
                    && (NULL == grp->gr_mem[1])
-                   && ('\0' == grp->gr_mem[0][0])) {
+                   && streq(grp->gr_mem[0], ""))
+               {
                        grp->gr_mem[0] = NULL;
                }
 
index 31162af18bfa398c0d5098ddaef8db8c59b937a6..9cd1688c998b1e78972325a67fc6018587135da0 100644 (file)
@@ -661,7 +661,7 @@ int main (int argc, char **argv)
                /* if we didn't get a user on the command line,
                   set it to NULL */
                get_pam_user (&pam_user);
-               if ((NULL != pam_user) && ('\0' == pam_user[0])) {
+               if ((NULL != pam_user) && streq(pam_user, "")) {
                        retcode = pam_set_item (pamh, PAM_USER, NULL);
                        PAM_FAIL_CHECK;
                }
@@ -838,7 +838,7 @@ int main (int argc, char **argv)
                        username = XMALLOC(max_size, char);
                        login_prompt(username, max_size);
 
-                       if ('\0' == username[0]) {
+                       if (streq(username, "")) {
                                /* Prompt for a new login */
                                free (username);
                                username = NULL;
@@ -963,7 +963,7 @@ int main (int argc, char **argv)
                 * guys won't see that the passwordless account exists at
                 * all).  --marekm
                 */
-               if (user_passwd[0] == '\0') {
+               if (streq(user_passwd, "")) {
                        pw_auth ("!", username, reason, NULL);
                }
 
index 56692e15d6f9edd804f5f13860e4801bbe1644e1..fd058a6565ad5c435e1b09a6249ae77a4f2bfcae 100644 (file)
@@ -29,7 +29,6 @@
 #ifndef USE_PAM
 #ident "$Id$"
 
-#include "prototypes.h"
     /*
      * This module implements a simple but effective form of login access
      * control based on login names and on host (or domain) names, internet
      *
      * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
      */
-#include <sys/types.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <syslog.h>
+#include <arpa/inet.h>         /* for inet_ntoa() */
 #include <ctype.h>
-#include <netdb.h>
+#include <errno.h>
 #include <grp.h>
+#include <netdb.h>
+#include <netinet/in.h>
 #ifdef PRIMARY_GROUP_MATCH
 #include <pwd.h>
 #endif
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
+#include <stddef.h>
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/param.h>
 #include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>         /* for inet_ntoa() */
+#include <sys/types.h>
+#include <syslog.h>
+#include <unistd.h>
 
+#include "prototypes.h"
 #include "sizeof.h"
 #include "string/strchr/strrspn.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -110,7 +111,7 @@ login_access(const char *user, const char *from)
                                continue;       /* comment line */
                        }
                        stpcpy(strrspn(line, " \t"), "");
-                       if (line[0] == '\0') {  /* skip blank lines */
+                       if (streq(line, "")) {  /* skip blank lines */
                                continue;
                        }
                        p = line;
@@ -182,7 +183,7 @@ static char *myhostname (void)
 {
        static char name[MAXHOSTNAMELEN + 1] = "";
 
-       if (name[0] == '\0') {
+       if (streq(name, "")) {
                gethostname (name, sizeof (name));
                stpcpy(&name[MAXHOSTNAMELEN], "");
        }
index 427ae586a2cb7f9ea9745acca5b31209cf0be5e4..17f961126d4b9acb0e612544874194ce1669b646 100644 (file)
@@ -150,7 +150,7 @@ static void check_perms (const struct group *grp,
                spw_free (spwd);
        }
 
-       if ((pwd->pw_passwd[0] == '\0') && (grp->gr_passwd[0] != '\0')) {
+       if (streq(pwd->pw_passwd, "") && (grp->gr_passwd[0] != '\0')) {
                needspasswd = true;
        }
 
@@ -188,8 +188,8 @@ static void check_perms (const struct group *grp,
                        goto failure;
                }
 
-               if (grp->gr_passwd[0] == '\0' ||
-                   !streq(cpasswd, grp->gr_passwd)) {
+               if (streq(grp->gr_passwd, "") ||
+                   !streq(grp->gr_passwd, cpasswd)) {
 #ifdef WITH_AUDIT
                        SNPRINTF(audit_buf, "authentication new-gid=%lu",
                                 (unsigned long) grp->gr_gid);
index e75b0b94f26e1ab8af44a827f4086f3f844fff21..be038172cf0f20f37ca88e1d453149c254005223 100644 (file)
@@ -441,7 +441,7 @@ static /*@observer@*/const char *pw_status (const char *pass)
        if (*pass == '*' || *pass == '!') {
                return "L";
        }
-       if (*pass == '\0') {
+       if (streq(pass, "")) {
                return "NP";
        }
        return "P";
index 67195ea0dc5530cab2d7fa054240e1d8914856e8..653b58beb9ad2c2cebe3c2cd34d86b1bd2174850 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -862,7 +862,7 @@ static void process_flags (int argc, char **argv)
        if (optind < argc) {
                STRTCPY(name, argv[optind++]);  /* use this login id */
        }
-       if ('\0' == name[0]) {          /* use default user */
+       if (streq(name, "")) {          /* use default user */
                struct passwd *root_pw = getpwnam ("root");
                if ((NULL != root_pw) && (0 == root_pw->pw_uid)) {
                        (void) strcpy (name, "root");
@@ -1080,7 +1080,7 @@ int main (int argc, char **argv)
        /*
         * Set the default shell.
         */
-       if ((NULL == shellstr) || ('\0' == shellstr[0])) {
+       if ((NULL == shellstr) || streq(shellstr, "")) {
                shellstr = SHELL;
        }
 
index 936b3a2f2e0d1d5f1970a3409004f62e59c5df89..8d961fd5b2fed3a27e5716cbbaa46c9779b1d19b 100644 (file)
@@ -86,7 +86,7 @@ check_su_auth(const char *actual_id, const char *wanted_id, bool su_to_root)
                stpcpy(strrspn(temp, " \t"), "");
 
                p = stpspn(temp, " \t");
-               if (*p == '#' || *p == '\0')
+               if (*p == '#' || streq(p, ""))
                        continue;
 
                to_users = strsep(&p, ":");
index 6af471b5949b2c8d4eefe97817625d2ff1d6eb6f..655a583abe6035a4bf92ace28b9f1fb6e8209ab4 100644 (file)
@@ -27,6 +27,7 @@
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "shadowlog.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 
 
@@ -153,7 +154,7 @@ main(int argc, char *argv[])
                 * it will work with standard getpass() (no NULL on EOF).
                 * --marekm
                 */
-               if ((NULL == pass) || ('\0' == *pass)) {
+               if ((NULL == pass) || streq(pass, "")) {
                        erase_pass (pass);
                        (void) puts ("");
 #ifdef TELINIT
index 891fd1420501c637fd0bad03fa8d845ff4e99590..a9944eef6ca5c963e7e979de40fe8f4034a5be7b 100644 (file)
@@ -439,7 +439,7 @@ get_defaults(void)
                 * Default Skeleton information
                 */
                else if (streq(buf, DSKEL)) {
-                       if ('\0' == *ccp)
+                       if (streq(ccp, ""))
                                ccp = SKEL_DIR;
 
                        if (prefix[0]) {
@@ -456,7 +456,7 @@ get_defaults(void)
                 * Default Usr Skeleton information
                 */
                else if (streq(buf, DUSRSKEL)) {
-                       if ('\0' == *ccp)
+                       if (streq(ccp, ""))
                                ccp = USRSKELDIR;
 
                        if (prefix[0]) {
@@ -472,7 +472,7 @@ get_defaults(void)
                 * Create by default user mail spool or not ?
                 */
                else if (streq(buf, DCREATE_MAIL_SPOOL)) {
-                       if (*ccp == '\0')
+                       if (streq(ccp, ""))
                                ccp = "no";
 
                        def_create_mail_spool = xstrdup(ccp);
@@ -482,7 +482,7 @@ get_defaults(void)
                 * By default do we add the user to the lastlog and faillog databases ?
                 */
                else if (streq(buf, DLOG_INIT)) {
-                       if (*ccp == '\0')
+                       if (streq(ccp, ""))
                                ccp = def_log_init;
 
                        def_log_init = xstrdup(ccp);
@@ -770,7 +770,7 @@ static int get_groups (char *list)
                user_groups[i++] = NULL;
        }
 
-       if ('\0' == *list) {
+       if (streq(list, "")) {
                return 0;
        }
 
index 6552c5ae7430fdc59a457a055eaa60a4fb89cabb..1e736763709791b0874d2c9a544f01fc26055d6e 100644 (file)
@@ -1131,7 +1131,7 @@ int main (int argc, char **argv)
         * Note: This is a best effort basis. The user may log in between,
         * a cron job may be started on her behalf, etc.
         */
-       if ((prefix[0] == '\0') && !Rflg && user_busy (user_name, user_id) != 0) {
+       if (streq(prefix, "") && !Rflg && user_busy(user_name, user_id) != 0) {
                if (!fflg) {
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER, Prog,
@@ -1264,7 +1264,7 @@ int main (int argc, char **argv)
         * Cancel any crontabs or at jobs. Have to do this before we remove
         * the entry from /etc/passwd.
         */
-       if (prefix[0] == '\0')
+       if (streq(prefix, ""))
                user_cancel (user_name);
        close_files ();
 
index f33aec31e336ada25d052f34ecb2cc53226bbb9a..69a19ff2728e48b43848847b29d0017887d5cf91 100644 (file)
@@ -227,7 +227,7 @@ static int get_groups (char *list)
         */
        user_groups[0] = NULL;
 
-       if ('\0' == *list) {
+       if (streq(list, "")) {
                return 0;
        }
 
@@ -2186,7 +2186,7 @@ int main (int argc, char **argv)
         * be changed while the user is logged in.
         * Note: no need to check if a prefix is specified...
         */
-       if ( (prefix[0] == '\0') &&  (uflg || lflg || dflg
+       if (streq(prefix, "") && (uflg || lflg || dflg
 #ifdef ENABLE_SUBIDS
                || Vflg || Wflg
 #endif                         /* ENABLE_SUBIDS */