]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Call NULL by its name
authorAlejandro Colomar <alx@kernel.org>
Wed, 1 Feb 2023 01:50:14 +0000 (02:50 +0100)
committerSerge Hallyn <serge@hallyn.com>
Thu, 2 Feb 2023 19:08:30 +0000 (13:08 -0600)
In variadic functions we still do the cast.  In POSIX, it's not
necessary, since NULL is required to be of type 'void *', and 'void *'
is guaranteed to have the same alignment and representation as 'char *'.
However, since ISO C still doesn't mandate that, and moreover they're
doing dubious stuff by adding nullptr, let's be on the cautious side.
Also, C++ requires that NULL is _not_ 'void *', but either plain 0 or
some magic stuff.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
31 files changed:
lib/gshadow.c
lib/port.c
lib/sgetgrent.c
lib/shadow.c
libmisc/age.c
libmisc/entry.c
libmisc/env.c
libmisc/isexpired.c
libmisc/list.c
libmisc/loginprompt.c
libmisc/pwdcheck.c
libmisc/shell.c
libmisc/sulog.c
src/chfn.c
src/chgpasswd.c
src/chpasswd.c
src/faillog.c
src/gpasswd.c
src/groupdel.c
src/groupmod.c
src/lastlog.c
src/login.c
src/login_nopam.c
src/newgrp.c
src/newusers.c
src/pwck.c
src/su.c
src/sulogin.c
src/useradd.c
src/userdel.c
src/usermod.c

index f075aa97eb79c2aac2430fb9ecd24a3a5be944c1..d9b267073bcfc0ad92cd66b6dc16b05e5c97fb09 100644 (file)
@@ -103,7 +103,7 @@ void endsgent (void)
                (void) fclose (shadow);
        }
 
-       shadow = (FILE *) 0;
+       shadow = NULL;
 }
 
 /*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *string)
@@ -399,7 +399,7 @@ void endsgent (void)
                nis_disabled = true;
        }
 #endif
-       while ((sgrp = getsgent ()) != (struct sgrp *) 0) {
+       while ((sgrp = getsgent ()) != NULL) {
                if (strcmp (name, sgrp->sg_name) == 0) {
                        break;
                }
index 90eb14987fdbdc0fecc49b049ba47c9a9b36889a..a100a7ce1110c72104d2e8e0a852ebe6db789f8a 100644 (file)
@@ -79,7 +79,7 @@ static void endportent (void)
                (void) fclose (ports);
        }
 
-       ports = (FILE *) 0;
+       ports = NULL;
 }
 
 /*
@@ -172,13 +172,13 @@ static struct port *getportent (void)
        }
        *cp = '\0';
        cp++;
-       port.pt_names[j + 1] = (char *) 0;
+       port.pt_names[j + 1] = NULL;
 
        /*
         * Get the list of user names.  It is the second colon
         * separated field, and is a comma separated list of user
         * names.  The entry '*' is used to specify all usernames.
-        * The last entry in the list is a (char *) 0 pointer.
+        * The last entry in the list is a NULL pointer.
         */
 
        if (':' != *cp) {
index ad4fcc86bb2b78f260575e3aaf6eaf01c2ee60e2..3d7495022cda2046c8db1687ab794590a1325e30 100644 (file)
@@ -34,7 +34,7 @@
  */
 static char **list (char *s)
 {
-       static char **members = 0;
+       static char **members = NULL;
        static int size = 0;    /* max members + 1 */
        int i;
        char **rbuf;
@@ -55,9 +55,9 @@ static char **list (char *s)
                        }
                        if (!rbuf) {
                                free (members);
-                               members = 0;
+                               members = NULL;
                                size = 0;
-                               return (char **) 0;
+                               return NULL;
                        }
                        members = rbuf;
                }
@@ -71,14 +71,14 @@ static char **list (char *s)
                        *s++ = '\0';
                }
        }
-       members[i] = (char *) 0;
+       members[i] = NULL;
        return members;
 }
 
 
 struct group *sgetgrent (const char *buf)
 {
-       static char *grpbuf = 0;
+       static char *grpbuf = NULL;
        static size_t size = 0;
        static char *grpfields[NFIELDS];
        static struct group grent;
@@ -91,9 +91,9 @@ struct group *sgetgrent (const char *buf)
                free (grpbuf);
                size = strlen (buf) + 1000;     /* at least: strlen(buf) + 1 */
                grpbuf = malloc (size);
-               if (!grpbuf) {
+               if (grpbuf == NULL) {
                        size = 0;
-                       return 0;
+                       return NULL;
                }
        }
        strcpy (grpbuf, buf);
@@ -112,16 +112,16 @@ struct group *sgetgrent (const char *buf)
                }
        }
        if (i < (NFIELDS - 1) || *grpfields[2] == '\0' || cp != NULL) {
-               return (struct group *) 0;
+               return NULL;
        }
        grent.gr_name = grpfields[0];
        grent.gr_passwd = grpfields[1];
        if (get_gid (grpfields[2], &grent.gr_gid) == 0) {
-               return (struct group *) 0;
+               return NULL;
        }
        grent.gr_mem = list (grpfields[3]);
        if (NULL == grent.gr_mem) {
-               return (struct group *) 0;      /* out of memory */
+               return NULL;    /* out of memory */
        }
 
        return &grent;
index 6a89a3f6123e1f8959b1f34087f19fd411a7aaa7..8959f4b0f677e156b8353f937748423fc4e40240 100644 (file)
@@ -94,7 +94,7 @@ void endspent (void)
                (void) fclose (shadow);
        }
 
-       shadow = (FILE *) 0;
+       shadow = NULL;
 }
 
 /*
@@ -336,9 +336,9 @@ struct spwd *fgetspent (FILE * fp)
        }
 
 #ifdef USE_NIS
-       while (fgets (buf, (int) sizeof buf, fp) != (char *) 0)
+       while (fgets (buf, (int) sizeof buf, fp) != NULL)
 #else
-       if (fgets (buf, (int) sizeof buf, fp) != (char *) 0)
+       if (fgets (buf, (int) sizeof buf, fp) != NULL)
 #endif
        {
                cp = strchr (buf, '\n');
@@ -511,7 +511,7 @@ struct spwd *getspnam (const char *name)
                nis_disabled = true;
        }
 #endif
-       while ((sp = getspent ()) != (struct spwd *) 0) {
+       while ((sp = getspent ()) != NULL) {
                if (strcmp (name, sp->sp_namp) == 0) {
                        break;
                }
index d10f71b959cccb6a84a9c45943dd4eb56bc04512..744bcd85d18583f1e300cf570999ae65cced2489 100644 (file)
@@ -112,7 +112,7 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
                        _exit (126);
                }
 
-               (void) execl (PASSWD_PROGRAM, PASSWD_PROGRAM, pw->pw_name, (char *) 0);
+               (void) execl (PASSWD_PROGRAM, PASSWD_PROGRAM, pw->pw_name, (char *) NULL);
                err = errno;
                perror ("Can't execute " PASSWD_PROGRAM);
                _exit ((ENOENT == err) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
@@ -139,7 +139,7 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
 
 void agecheck (/*@null@*/const struct spwd *sp)
 {
-       long now = (long) time ((time_t *) 0) / SCALE;
+       long now = (long) time(NULL) / SCALE;
        long remain;
 
        if (NULL == sp) {
index 87f575450012e7c6f964a3f476b7eeabdd93cfc5..cc4029d0f8539d6a850bb82a64e793185ead30fc 100644 (file)
@@ -24,7 +24,7 @@ void pw_entry (const char *name, struct passwd *pwent)
        struct spwd *spwd;
 
        if (!(passwd = getpwnam (name))) { /* local, no need for xgetpwnam */
-               pwent->pw_name = (char *) 0;
+               pwent->pw_name = NULL;
                return;
        } else {
                pwent->pw_name = xstrdup (passwd->pw_name);
index c6ab6727610a20ee1c7309702c01cab6f4c5f220..859dca08a22d6c14e1414fe3acd67a653d7f35a1 100644 (file)
@@ -41,7 +41,7 @@ static const char *const forbid[] = {
        "PATH=",
        "SHELL=",
        "SHLIB_PATH=",
-       (char *) 0
+       NULL
 };
 
 /* these are allowed, but with no slashes inside
@@ -50,7 +50,7 @@ static const char *const noslash[] = {
        "LANG=",
        "LANGUAGE=",
        "LC_",                  /* anything with the LC_ prefix */
-       (char *) 0
+       NULL
 };
 
 /*
index ff203967454d07d68f9c150104abfe4385d25a4d..5813015fb58d9e7888eeb5239440804ab1dba155 100644 (file)
@@ -40,7 +40,7 @@ int isexpired (const struct passwd *pw, /*@null@*/const struct spwd *sp)
 {
        long now;
 
-       now = (long) time ((time_t *) 0) / SCALE;
+       now = (long) time(NULL) / SCALE;
 
        if (NULL == sp) {
                return 0;
index 9d7ec77ba9da2d67c5fc664042a633bf7d2fff2b..9470b06cccb2b8297d69557622719bf72ad53ab2 100644 (file)
@@ -33,7 +33,7 @@
         * pointer if it is present.
         */
 
-       for (i = 0; list[i] != (char *) 0; i++) {
+       for (i = 0; list[i] != NULL; i++) {
                if (strcmp (list[i], member) == 0) {
                        return list;
                }
         * is returned to the invoker.
         */
 
-       for (i = 0; list[i] != (char *) 0; i++) {
+       for (i = 0; list[i] != NULL; i++) {
                tmp[i] = list[i];
        }
 
        tmp[i] = xstrdup (member);
-       tmp[i+1] = (char *) 0;
+       tmp[i+1] = NULL;
 
        return tmp;
 }
@@ -83,7 +83,7 @@
         * pointer if it is not present.
         */
 
-       for (i = j = 0; list[i] != (char *) 0; i++) {
+       for (i = j = 0; list[i] != NULL; i++) {
                if (strcmp (list[i], member) != 0) {
                        j++;
                }
         * is returned to the invoker.
         */
 
-       for (i = j = 0; list[i] != (char *) 0; i++) {
+       for (i = j = 0; list[i] != NULL; i++) {
                if (strcmp (list[i], member) != 0) {
                        tmp[j] = list[i];
                        j++;
                }
        }
 
-       tmp[j] = (char *) 0;
+       tmp[j] = NULL;
 
        return tmp;
 }
                list++;
        }
 
-       tmp[i] = (char *) 0;
+       tmp[i] = NULL;
        return tmp;
 }
 
@@ -217,7 +217,7 @@ bool is_on_list (char *const *list, const char *member)
         */
 
        if ('\0' == *members) {
-               *array = (char *) 0;
+               *array = NULL;
                free (members);
                return array;
        }
@@ -235,7 +235,7 @@ bool is_on_list (char *const *list, const char *member)
                        cp2++;
                        cp = cp2;
                } else {
-                       array[i + 1] = (char *) 0;
+                       array[i + 1] = NULL;
                        break;
                }
        }
index 6ada2d055b54ad4ca9c0e8fd6290f151b10f8531..0032078385bff82a236623a969796b675bf8cd4a 100644 (file)
@@ -122,7 +122,7 @@ void login_prompt (const char *prompt, char *name, int namesize)
                int envc;
 
                for (envc = 0; envc < MAX_ENV; envc++) {
-                       nvar = strtok ((0 != envc) ? (char *) 0 : cp, " \t,");
+                       nvar = strtok ((0 != envc) ? NULL : cp, " \t,");
                        if (NULL == nvar) {
                                break;
                        }
index e72920e8c1dbd2160d8953692bb3c6dc25f60ffe..a1f85cefe6164b55bae5317621597ca7c5ffd133 100644 (file)
@@ -26,7 +26,7 @@ void passwd_check (const char *user, const char *passwd, unused const char *prog
        if (NULL != sp) {
                passwd = sp->sp_pwdp;
        }
-       if (pw_auth (passwd, user, PW_LOGIN, (char *) 0) != 0) {
+       if (pw_auth (passwd, user, PW_LOGIN, NULL) != 0) {
                SYSLOG ((LOG_WARN, "incorrect password for `%s'", user));
                (void) sleep (1);
                fprintf (log_get_logfd(), _("Incorrect password for %s.\n"), user);
index 7c67500d0e73ef6f42518b214d8a4183307bf536..b0d7e87d0be59f687ba94fde5b0495fde6c66720 100644 (file)
@@ -33,7 +33,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
        char arg0[1024];
        int err;
 
-       if (file == (char *) 0) {
+       if (file == NULL) {
                errno = EINVAL;
                return errno;
        }
@@ -44,7 +44,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
         * that.  So, we determine the 0'th entry only if they
         * don't want to tell us what it is themselves.
         */
-       if (arg == (char *) 0) {
+       if (arg == NULL) {
                (void) snprintf (arg0, sizeof arg0, "-%s", Basename (file));
                arg0[sizeof arg0 - 1] = '\0';
                arg = arg0;
@@ -55,7 +55,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
         * able to figure out what we are up to without too much
         * grief.
         */
-       (void) execle (file, arg, (char *) 0, envp);
+       (void) execle (file, arg, (char *) NULL, envp);
        err = errno;
 
        if (access (file, R_OK|X_OK) == 0) {
@@ -63,7 +63,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
                 * Assume this is a shell script (with no shebang).
                 * Interpret it with /bin/sh
                 */
-               (void) execle (SHELL, "sh", "-", file, (char *)0, envp);
+               (void) execle (SHELL, "sh", "-", file, (char *) NULL, envp);
                err = errno;
        }
 
index 3e956134dee84405f2684298b5924adeac323fb1..2ef22b2e16da7e77be4dc03ae5d4b3b135d740aa 100644 (file)
@@ -64,7 +64,7 @@ void sulog (const char *tty, bool success, const char *oldname, const char *name
                /* Do not return if the group permission were raised. */
                exit (EXIT_FAILURE);
        }
-       if (fp == (FILE *) 0) {
+       if (fp == NULL) {
                return;         /* can't open or create logfile */
        }
 
index b1793e18390f0c1bbd55b40a0dd6f0e150049055..246e2e82d37532bda54d920ee1dd9810e349d57a 100644 (file)
@@ -510,28 +510,28 @@ static void get_old_fields (const char *gecos)
         * Now get the full name. It is the first comma separated field in
         * the GECOS field.
         */
-       cp = copy_field (old_gecos, fflg ? (char *) 0 : fullnm, slop);
+       cp = copy_field (old_gecos, fflg ? NULL : fullnm, slop);
 
        /*
         * Now get the room number. It is the next comma separated field,
         * if there is indeed one.
         */
        if (NULL != cp) {
-               cp = copy_field (cp, rflg ? (char *) 0 : roomno, slop);
+               cp = copy_field (cp, rflg ? NULL : roomno, slop);
        }
 
        /*
         * Now get the work phone number. It is the third field.
         */
        if (NULL != cp) {
-               cp = copy_field (cp, wflg ? (char *) 0 : workph, slop);
+               cp = copy_field (cp, wflg ? NULL : workph, slop);
        }
 
        /*
         * Now get the home phone number. It is the fourth field.
         */
        if (NULL != cp) {
-               cp = copy_field (cp, hflg ? (char *) 0 : homeph, slop);
+               cp = copy_field (cp, hflg ? NULL : homeph, slop);
        }
 
        /*
index d17acb675f5c66bc614f31baabf239db69141458..f6c92293934521efad839ed652258b30a17161fd 100644 (file)
@@ -441,7 +441,7 @@ int main (int argc, char **argv)
         * group entry for each group will be looked up in the appropriate
         * file (gshadow or group) and the password changed.
         */
-       while (fgets (buf, (int) sizeof buf, stdin) != (char *) 0) {
+       while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
                line++;
                cp = strrchr (buf, '\n');
                if (NULL != cp) {
index 48d5178b6cddf66e7b72b50c5f05b9ecd45a5d43..e3188a768a6d3c3d07ff3f2e38aafdda5c715a74 100644 (file)
@@ -482,7 +482,7 @@ int main (int argc, char **argv)
         * last change date is set in the age only if aging information is
         * present.
         */
-       while (fgets (buf, (int) sizeof buf, stdin) != (char *) 0) {
+       while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
                line++;
                cp = strrchr (buf, '\n');
                if (NULL != cp) {
@@ -491,7 +491,7 @@ int main (int argc, char **argv)
                        if (feof (stdin) == 0) {
 
                                // Drop all remaining characters on this line.
-                               while (fgets (buf, (int) sizeof buf, stdin) != (char *) 0) {
+                               while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
                                        cp = strchr (buf, '\n');
                                        if (cp != NULL) {
                                                break;
index 0f94836f7b2f86768cacbf4a31122ba8a545b0bd..72b8a956df99113f444efd23d5c4f7b51911b88a 100644 (file)
@@ -57,7 +57,7 @@ static bool rflg = false;     /* reset the counters of login failures */
 
 static struct stat statbuf;    /* fstat buffer for file size */
 
-#define        NOW     (time((time_t *) 0))
+#define        NOW     time(NULL)
 
 static /*@noreturn@*/void usage (int status)
 {
index e8befac35c3d3a05cf40e7fdd0f66a12760e379a..a1739fcec37ab442f31f7f36c3a72db93d613dd1 100644 (file)
@@ -721,7 +721,7 @@ static void check_perms (const struct group *gr)
                 * --marekm
                 */
                if (!amroot) {
-                       if (gr->gr_mem[0] == (char *) 0) {
+                       if (gr->gr_mem[0] == NULL) {
                                failure ();
                        }
 
index c84faa799ac092c7d6615f573c046866e91b8cee..a9b15dca9fde83e8ccdb24b9737c509e82a0fd1d 100644 (file)
@@ -275,7 +275,7 @@ static void group_busy (gid_t gid)
         * If pwd isn't NULL, it stopped because the gid's matched.
         */
 
-       if (pwd == (struct passwd *) 0) {
+       if (pwd == NULL) {
                return;
        }
 
index 8c219194790ba807c201e91b377aaf4a568e48de..4921aca3f3f7f0e985056c67a93bfb1821db1570 100644 (file)
@@ -248,7 +248,7 @@ static void grp_update (void)
                        if (NULL != grp.gr_mem[0])
                                gr_free_members(&grp);
                        grp.gr_mem = (char **)xmalloc(sizeof(char *));
-                       grp.gr_mem[0] = (char *)0;
+                       grp.gr_mem[0] = NULL;
                } else {
                        // append to existing groups
                        if (NULL != grp.gr_mem[0])
index f5c0a5cc8cbb60172ca0bf183f08fd2da6cc080e..3338d6bd1a4614ba2b2bbbd844caffe34e7bac54 100644 (file)
@@ -56,7 +56,7 @@ static bool bflg = false;     /* print excludes most recent days */
 static bool Cflg = false;      /* clear record for user */
 static bool Sflg = false;      /* set record for user */
 
-#define        NOW     (time ((time_t *) 0))
+#define        NOW     time(NULL)
 
 static /*@noreturn@*/void usage (int status)
 {
index ea2b52ee4113c380fbc9b708be4fed2277748191..7d247cc4f9169cd840091678de2cba13f2bba006 100644 (file)
@@ -974,7 +974,7 @@ int main (int argc, char **argv)
                        goto auth_ok;
                }
 
-               if (pw_auth (user_passwd, username, reason, (char *) 0) == 0) {
+               if (pw_auth (user_passwd, username, reason, NULL) == 0) {
                        goto auth_ok;
                }
 
@@ -1041,7 +1041,7 @@ int main (int argc, char **argv)
                 * all).  --marekm
                 */
                if (user_passwd[0] == '\0') {
-                       pw_auth ("!", username, reason, (char *) 0);
+                       pw_auth ("!", username, reason, NULL);
                }
 
                /*
@@ -1081,7 +1081,7 @@ int main (int argc, char **argv)
         * by Ivan Nejgebauer <ian@unsux.ns.ac.yu>.  --marekm
         */
        if (   getdef_bool ("PORTTIME_CHECKS_ENAB")
-           && !isttytime (username, tty, time ((time_t *) 0))) {
+           && !isttytime (username, tty, time (NULL))) {
                SYSLOG ((LOG_WARN, "invalid login time for '%s'%s",
                         username, fromhost));
                closelog ();
@@ -1308,7 +1308,7 @@ int main (int argc, char **argv)
                err = shell (tmp, pwd->pw_shell, newenvp); /* fake shell */
        } else {
                /* exec the shell finally */
-               err = shell (pwd->pw_shell, (char *) 0, newenvp);
+               err = shell (pwd->pw_shell, NULL, newenvp);
        }
 
        return ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
index 18072a43aa61b1858f8da5d0d5b28a15fc44084d..e3c00ef0691cca83e196c6a303a888354b6d6fee 100644 (file)
@@ -117,9 +117,9 @@ int login_access (const char *user, const char *from)
                                continue;
                        }
                        if (   ((perm = strtok (line, fs)) == NULL)
-                           || ((users = strtok ((char *) 0, fs)) == NULL)
-                           || ((froms = strtok ((char *) 0, fs)) == NULL)
-                           || (strtok ((char *) 0, fs) != NULL)) {
+                           || ((users = strtok (NULL, fs)) == NULL)
+                           || ((froms = strtok (NULL, fs)) == NULL)
+                           || (strtok (NULL, fs) != NULL)) {
                                SYSLOG ((LOG_ERR,
                                         "%s: line %d: bad field count",
                                         TABLE, lineno));
@@ -154,7 +154,7 @@ static bool list_match (char *list, const char *item, bool (*match_fn) (const ch
         * a match, look for an "EXCEPT" list and recurse to determine whether
         * the match is affected by any exceptions.
         */
-       for (tok = strtok (list, sep); tok != NULL; tok = strtok ((char *) 0, sep)) {
+       for (tok = strtok (list, sep); tok != NULL; tok = strtok (NULL, sep)) {
                if (strcasecmp (tok, "EXCEPT") == 0) {  /* EXCEPT: give up */
                        break;
                }
@@ -166,10 +166,10 @@ static bool list_match (char *list, const char *item, bool (*match_fn) (const ch
 
        /* Process exceptions to matches. */
        if (match) {
-               while (   ((tok = strtok ((char *) 0, sep)) != NULL)
+               while (   ((tok = strtok (NULL, sep)) != NULL)
                       && (strcasecmp (tok, "EXCEPT") != 0))
                        /* VOID */ ;
-               if (tok == 0 || !list_match ((char *) 0, item, match_fn)) {
+               if (tok == 0 || !list_match (NULL, item, match_fn)) {
                        return (match);
                }
        }
@@ -193,9 +193,9 @@ static char *myhostname (void)
 static bool
 netgroup_match (const char *group, const char *machine, const char *user)
 {
-       static char *mydomain = (char *)0;
+       static char *mydomain = NULL;
 
-       if (mydomain == (char *)0) {
+       if (mydomain == NULL) {
                static char domain[MAXHOSTNAMELEN + 1];
 
                getdomainname (domain, MAXHOSTNAMELEN);
@@ -228,7 +228,7 @@ static bool user_match (const char *tok, const char *string)
                        && from_match (at + 1, myhostname ()));
 #if HAVE_INNETGR
        } else if (tok[0] == '@') {     /* netgroup */
-               return (netgroup_match (tok + 1, (char *) 0, string));
+               return (netgroup_match (tok + 1, NULL, string));
 #endif
        } else if (string_match (tok, string)) {        /* ALL or exact match */
                return true;
@@ -303,7 +303,7 @@ static bool from_match (const char *tok, const char *string)
         */
 #if HAVE_INNETGR
        if (tok[0] == '@') {    /* netgroup */
-               return (netgroup_match (tok + 1, string, (char *) 0));
+               return (netgroup_match (tok + 1, string, NULL));
        } else
 #endif
        if (string_match (tok, string)) {       /* ALL or exact match */
index bdc007fe248bcbdeef7ca824fc8b082a4e5123a8..7e949c95a4fff64af25eb942ee364ff1beff0b99 100644 (file)
@@ -504,7 +504,7 @@ int main (int argc, char **argv)
                if ((argc > 0) && (argv[0][0] == '-')) {
                        usage ();
                        goto failure;
-               } else if (argv[0] != (char *) 0) {
+               } else if (argv[0] != NULL) {
                        group = argv[0];
                } else {
                        /*
@@ -740,7 +740,7 @@ int main (int argc, char **argv)
         */
        if (cflag) {
                closelog ();
-               execl (SHELL, "sh", "-c", command, (char *) 0);
+               execl (SHELL, "sh", "-c", command, (char *) NULL);
 #ifdef WITH_AUDIT
                snprintf (audit_buf, sizeof(audit_buf),
                          "changing new-gid=%lu", (unsigned long) gid);
@@ -820,7 +820,7 @@ int main (int argc, char **argv)
         * Exec the login shell and go away. We are trying to get back to
         * the previous environment which should be the user's login shell.
         */
-       err = shell (prog, initflag ? (char *) 0 : progbase, newenvp);
+       err = shell (prog, initflag ? NULL : progbase, newenvp);
        exit ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
        /*@notreached@*/
       failure:
index deeb36145028f2a755883ed176e956d32b945433..22db1e9aa9b460a558d9b932fe042f416e1c51f7 100644 (file)
@@ -1088,7 +1088,7 @@ int main (int argc, char **argv)
         * over 100 is allocated. The pw_gid field will be updated with that
         * value.
         */
-       while (fgets (buf, (int) sizeof buf, stdin) != (char *) 0) {
+       while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
                line++;
                cp = strrchr (buf, '\n');
                if (NULL != cp) {
index eaa4163f467299090f49d6fb199a929d8424ef5f..83aaaca93ed96acaca9bb4c853b358cd8c506f5b 100644 (file)
@@ -812,7 +812,7 @@ static void check_spw_file (int *errors, bool *changed)
                 * Warn if last password change in the future.  --marekm
                 */
                if (!quiet) {
-                       time_t t = time ((time_t *) 0);
+                       time_t t = time (NULL);
                        if (   (t != 0)
                            && (spw->sp_lstchg > (long) t / SCALE)) {
                                printf (_("user %s: last password change in the future\n"),
index 9578ab2b9227a6ed55a6a7ce338362b237c8e524..4fe86fee8f31c02a443f1754b7f5f89984b64462 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -575,7 +575,7 @@ static void check_perms_nopam (const struct passwd *pw)
         * The first character of an administrator defined method is an '@'
         * character.
         */
-       if (pw_auth (password, name, PW_SU, (char *) 0) != 0) {
+       if (pw_auth (password, name, PW_SU, NULL) != 0) {
                SYSLOG (((pw->pw_uid != 0)? LOG_NOTICE : LOG_WARN,
                         "Authentication failed for %s", name));
                fprintf(stderr, _("%s: Authentication failure\n"), Prog);
@@ -598,7 +598,7 @@ static void check_perms_nopam (const struct passwd *pw)
         * there is a "SU" entry in the /etc/porttime file denying access to
         * the account.
         */
-       if (!isttytime (name, "SU", time ((time_t *) 0))) {
+       if (!isttytime (name, "SU", time (NULL))) {
                SYSLOG (((0 != pw->pw_uid) ? LOG_WARN : LOG_CRIT,
                         "SU by %s to restricted account %s",
                         caller_name, name));
@@ -1130,7 +1130,7 @@ int main (int argc, char **argv)
                int fd = open ("/dev/tty", O_RDWR);
 
                if (fd >= 0) {
-                       err = ioctl (fd, TIOCNOTTY, (char *) 0);
+                       err = ioctl (fd, TIOCNOTTY, (char *) NULL);
                        (void) close (fd);
                } else if (ENXIO == errno) {
                        /* There are no controlling terminal already */
index 0d5b411dc663850c1af9f503d0290a23e2502664..002dc9304a1747a2b6a288e969f6e96a78b65e16 100644 (file)
@@ -127,7 +127,7 @@ static void catch_signals (unused int sig)
        while (true) {          /* repeatedly get login/password pairs */
                char *cp;
                pw_entry (name, &pwent);        /* get entry from password file */
-               if (pwent.pw_name == (char *) 0) {
+               if (pwent.pw_name == NULL) {
                        /*
                         * Fail secure
                         */
@@ -155,7 +155,7 @@ static void catch_signals (unused int sig)
                        erase_pass (cp);
                        (void) puts ("");
 #ifdef TELINIT
-                       execl (PATH_TELINIT, "telinit", RUNLEVEL, (char *) 0);
+                       execl (PATH_TELINIT, "telinit", RUNLEVEL, (char *) NULL);
 #endif
                        exit (0);
                }
@@ -177,7 +177,7 @@ static void catch_signals (unused int sig)
        (void) puts (_("Entering System Maintenance Mode"));
 
        /* exec the shell finally. */
-       err = shell (pwent.pw_shell, (char *) 0, environ);
+       err = shell (pwent.pw_shell, NULL, environ);
 
        return ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
 }
index 1ade54a2aaba960067be8230073ca204f92efeb3..2da418b367658cb913ee82a4117c5c456f0fe92a 100644 (file)
@@ -894,7 +894,7 @@ static int get_groups (char *list)
        close_group_files ();
        unlock_group_files ();
 
-       user_groups[ngroups] = (char *) 0;
+       user_groups[ngroups] = NULL;
 
        /*
         * Any errors in finding group names are fatal
@@ -2546,7 +2546,7 @@ int main (int argc, char **argv)
        /*
         * Initialize the list to be empty
         */
-       user_groups[0] = (char *) 0;
+       user_groups[0] = NULL;
 
 
        is_shadow_pwd = spw_file_present ();
index 7012b0e06fa1c10473d507289faa9c6f33d31ef0..6da6db1ba839d2f362f771681749a379ce648f11 100644 (file)
@@ -763,7 +763,7 @@ static void user_cancel (const char *user)
        }
        argv[0] = cmd;
        argv[1] = user;
-       argv[2] = (char *)0;
+       argv[2] = NULL;
        (void) run_command (cmd, argv, NULL, &status);
 }
 
index c1a5b2cdc11e0690028f4d7b6d2deecf2cdd21dd..1c65a934b8dd0cfc87aca8af7655968f80b1dee2 100644 (file)
@@ -205,7 +205,7 @@ static int get_groups (char *list)
        /*
         * Initialize the list to be empty
         */
-       user_groups[0] = (char *) 0;
+       user_groups[0] = NULL;
 
        if ('\0' == *list) {
                return 0;
@@ -280,7 +280,7 @@ static int get_groups (char *list)
                gr_free ((struct group *)grp);
        } while (NULL != list);
 
-       user_groups[ngroups] = (char *) 0;
+       user_groups[ngroups] = NULL;
 
        /*
         * Any errors in finding group names are fatal
@@ -2154,7 +2154,7 @@ int main (int argc, char **argv)
 
        sys_ngroups = sysconf (_SC_NGROUPS_MAX);
        user_groups = (char **) malloc (sizeof (char *) * (1 + sys_ngroups));
-       user_groups[0] = (char *) 0;
+       user_groups[0] = NULL;
 
        is_shadow_pwd = spw_file_present ();
 #ifdef SHADOWGRP