]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Consistently use sizeof() as if it were a function
authorAlejandro Colomar <alx@kernel.org>
Tue, 23 Jul 2024 20:42:54 +0000 (22:42 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 28 Nov 2025 14:39:37 +0000 (08:39 -0600)
sizeof(foo)

-  No spaces.
Not:  sizeof (foo)
-  Parentheses.
Not:  sizeof foo
-  No parentheses wrapping sizeof itself
Not:  (sizeof foo)

This patch can be approximated with the following semantic patch:

$ cat ~/tmp/spatch/sizeof.sp
@@
identifier a, b;
@@

- sizeof a->b
+ sizeof(a->b)

@@
identifier a, b;
@@

- sizeof a.b
+ sizeof(a.b)

@@
identifier x;
@@

- sizeof x
+ sizeof(x)

@@
identifier x;
@@

- sizeof *x
+ sizeof(*x)

@@
identifier x;
@@

- (sizeof(x))
+ sizeof(x)

@@
identifier x;
@@

- (sizeof(*x))
+ sizeof(*x)

Applied as

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

The differences between the actual patch and the approximation via the
semantic patch from above are whitespace only.  When reviewing, it'll
be useful to diff with '-w'.

Link: <https://lkml.org/lkml/2012/7/11/103>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
33 files changed:
lib/commonio.c
lib/console.c
lib/copydir.c
lib/env.c
lib/failure.c
lib/fields.c
lib/getdef.c
lib/hushed.c
lib/log.c
lib/loginprompt.c
lib/setupenv.c
lib/subordinateio.c
lib/ttytype.c
lib/tz.c
lib/user_busy.c
lib/utmp.c
src/chage.c
src/chfn.c
src/chgpasswd.c
src/chpasswd.c
src/chsh.c
src/faillog.c
src/groupadd.c
src/groupmod.c
src/grpconv.c
src/lastlog.c
src/login.c
src/login_nopam.c
src/newusers.c
src/pwconv.c
src/suauth.c
src/useradd.c
src/usermod.c

index d37ba23c9f8077dfe8aa8557046d9d5d21a88175..85bde16b9bf571ec6b09f640b31e458afbc95bab 100644 (file)
@@ -181,7 +181,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
                errno = EINVAL;
                return 0;
        }
-       len = read (fd, buf, sizeof (buf) - 1);
+       len = read(fd, buf, sizeof(buf) - 1);
        close (fd);
        if (len <= 0) {
                if (log) {
@@ -767,7 +767,7 @@ commonio_sort (struct commonio_db *db, int (*cmp) (const void *, const void *))
                entries[n] = ptr;
                n++;
        }
-       qsort (entries, n, sizeof (struct commonio_entry *), cmp);
+       qsort(entries, n, sizeof(struct commonio_entry *), cmp);
 
        /* Take care of the head and tail separately */
        db->head = entries[0];
@@ -905,7 +905,7 @@ int commonio_close (struct commonio_db *db, bool process_selinux)
                goto fail;
        }
 
-       memzero (&sb, sizeof sb);
+       memzero(&sb, sizeof(sb));
        if (NULL != db->fp) {
                if (fstat (fileno (db->fp), &sb) != 0) {
                        (void) fclose (db->fp);
index 66cec24533fcda40e55ba3e0267fd2629b3d2c7c..8e4efb59ccf165d423d16289924b012ace30d151 100644 (file)
@@ -76,7 +76,7 @@ is_listed(const char *cfgin, const char *tty, bool def)
         * See if this tty is listed in the console file.
         */
 
-       while (fgets (buf, sizeof (buf), fp) != NULL) {
+       while (fgets(buf, sizeof(buf), fp) != NULL) {
                stpsep(buf, "\n");
                if (streq(buf, tty)) {
                        (void) fclose (fp);
index 5d91d201ed9f8f77be3775116e7c682d95c3bd29..69eba53381476d924cc5abae34c548ec6df64059 100644 (file)
@@ -757,7 +757,7 @@ static int copy_file (const struct path_info *src, const struct path_info *dst,
                char buf[8192];
                ssize_t cnt;
 
-               cnt = read (ifd, buf, sizeof buf);
+               cnt = read(ifd, buf, sizeof(buf));
                if (cnt < 0) {
                        if (errno == EINTR) {
                                continue;
index 37951b3b2c9ab30b61f0510b206d4ffb838fd55e..95b4ed5c51bc0a19be395706a48c3e55269c98f2 100644 (file)
--- a/lib/env.c
+++ b/lib/env.c
@@ -164,7 +164,7 @@ void set_env (int argc, char *const *argv)
        char  *cp;
 
        for (; argc > 0; argc--, argv++) {
-               if (strlen (*argv) >= sizeof variable) {
+               if (strlen(*argv) >= sizeof(variable)) {
                        continue;       /* ignore long entries */
                }
 
index 369b215abcadd646502bf6ee22847958f687ace3..24b8c5dfe658eb7b2bfc6401ce0d8060b69c048a 100644 (file)
@@ -34,7 +34,7 @@
 void failure (uid_t uid, const char *tty, struct faillog *fl)
 {
        int fd;
-       off_t offset_uid = (off_t) (sizeof *fl) * uid;
+       off_t offset_uid = (off_t) sizeof(*fl) * uid;
 
        /*
         * Don't do anything if failure logging isn't set up.
@@ -59,7 +59,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl)
         */
 
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
-           || (read (fd, fl, sizeof *fl) != (ssize_t) sizeof *fl)) {
+           || (read(fd, fl, sizeof(*fl)) != (ssize_t) sizeof(*fl))) {
                /* This is not necessarily a failure. The file is
                 * initially zero length.
                 *
@@ -67,7 +67,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl)
                 * might reset the counter. But the new failure will be
                 * logged.
                 */
-               memzero (fl, sizeof *fl);
+               memzero(fl, sizeof(*fl));
        }
 
        /*
@@ -92,7 +92,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl)
         */
 
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
-           || (write_full(fd, fl, sizeof *fl) == -1)) {
+           || (write_full(fd, fl, sizeof(*fl)) == -1)) {
                goto err_write;
        }
 
@@ -150,7 +150,7 @@ int failcheck (uid_t uid, struct faillog *fl, bool failed)
 {
        int fd;
        struct faillog fail;
-       off_t offset_uid = (off_t) (sizeof *fl) * uid;
+       off_t offset_uid = (off_t) sizeof(*fl) * uid;
 
        /*
         * Suppress the check if the log file isn't there.
@@ -182,7 +182,7 @@ int failcheck (uid_t uid, struct faillog *fl, bool failed)
         */
 
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
-           || (read (fd, fl, sizeof *fl) != (ssize_t) sizeof *fl)) {
+           || (read(fd, fl, sizeof(*fl)) != (ssize_t) sizeof(*fl))) {
                (void) close (fd);
                return 1;
        }
@@ -204,7 +204,7 @@ int failcheck (uid_t uid, struct faillog *fl, bool failed)
                fail.fail_cnt = 0;
 
                if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
-                   || (write_full(fd, &fail, sizeof fail) == -1)) {
+                   || (write_full(fd, &fail, sizeof(fail)) == -1)) {
                            goto err_write;
                }
 
index 72b9c7a7ec96c0816279cf2b4cad444a95fbfb90..2a6f54e5f264011b165f6eb817ce8423cd9a5b54 100644 (file)
@@ -62,8 +62,8 @@ change_field(char *buf, size_t maxsize, const char *prompt)
        char newf[200];
        char *cp;
 
-       if (maxsize > sizeof (newf)) {
-               maxsize = sizeof (newf);
+       if (maxsize > sizeof(newf)) {
+               maxsize = sizeof(newf);
        }
 
        printf ("\t%s [%s]: ", prompt, buf);
index 765cddfa19963f9922ef4db08f834da6e6d371fe..930b350bde6ade43ab4f41145e269a0444a3ddbf 100644 (file)
@@ -553,7 +553,7 @@ static void def_load (void)
        /*
         * Go through all of the lines in the file.
         */
-       while (fgets (buf, sizeof (buf), fp) != NULL) {
+       while (fgets(buf, sizeof(buf), fp) != NULL) {
 
                /*
                 * Trim trailing whitespace.
index 530996f40ca1bddecc838d6594e0ec376d9846e6..aadc287229878a42525d45f123c0cf7daac05572 100644 (file)
@@ -73,7 +73,7 @@ bool hushed (const char *username)
        if (NULL == fp) {
                return false;
        }
-       for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) {
+       for (found = false; !found && (fgets(buf, sizeof(buf), fp) == buf);) {
                stpsep(buf, "\n");
                found = streq(buf, pw->pw_shell) ||
                        streq(buf, pw->pw_name);
index d812b41293f823e56de4172300024563a66cda20..92d5336dffa0472a1f8c4b9b31815910a26a3d80 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -55,7 +55,7 @@ void dolastlog (
         * for this UID.  Negative UID's will create problems, but ...
         */
 
-       offset = (off_t) pw->pw_uid * sizeof newlog;
+       offset = (off_t) pw->pw_uid * sizeof(newlog);
 
        if (lseek (fd, offset, SEEK_SET) != offset) {
                SYSLOG ((LOG_WARN,
@@ -71,8 +71,8 @@ void dolastlog (
         * the way we read the old one in.
         */
 
-       if (read (fd, &newlog, sizeof newlog) != (ssize_t) sizeof newlog) {
-               memzero (&newlog, sizeof newlog);
+       if (read(fd, &newlog, sizeof(newlog)) != (ssize_t) sizeof(newlog)) {
+               memzero(&newlog, sizeof(newlog));
        }
        if (NULL != ll) {
                *ll = newlog;
@@ -86,7 +86,7 @@ void dolastlog (
        strncpy_a(newlog.ll_host, host);
 #endif
        if (   (lseek (fd, offset, SEEK_SET) != offset)
-           || (write_full(fd, &newlog, sizeof newlog) == -1)) {
+           || (write_full(fd, &newlog, sizeof(newlog)) == -1)) {
                goto err_write;
        }
 
index 51cbc3de3ff1782bbd4366207a0242b3249d80e1..36ae7061652978809c17a3c2c410f329c745dea2 100644 (file)
@@ -73,7 +73,7 @@ login_prompt(char *name, int namesize)
                        (void) fclose (fp);
                }
        }
-       (void) gethostname (buf, sizeof buf);
+       (void) gethostname(buf, sizeof(buf));
        printf (_("\n%s login: "), buf);
        (void) fflush (stdout);
 
@@ -83,7 +83,7 @@ login_prompt(char *name, int namesize)
         */
 
        memzero_a(buf);
-       if (fgets (buf, sizeof buf, stdin) != buf) {
+       if (fgets(buf, sizeof(buf), stdin) != buf) {
                exit (EXIT_FAILURE);
        }
 
index 1b9a417b1a92e955f46c8367a8da967aa282c528..1485f69e2cd03f67d7b00a9e0c7fe360a29cdf80 100644 (file)
@@ -55,7 +55,7 @@ static void read_env_file (const char *filename)
        if (NULL == fp) {
                return;
        }
-       while (fgets (buf, (int)(sizeof buf), fp) == buf) {
+       while (fgets(buf, (int) sizeof(buf), fp) == buf) {
                if (stpsep(buf, "\n") == NULL)
                        break;
 
index ff9e75b885e0f6489a83e30c0a92f5119ff37f19..487d7d48fcec9366547cc72bb437bbab72f8c49a 100644 (file)
@@ -93,7 +93,7 @@ subordinate_parse(const char *line)
         * Copy the string to a temporary buffer so the substrings can
         * be modified to be NULL terminated.
         */
-       if (strlen (line) >= sizeof rangebuf)
+       if (strlen(line) >= sizeof(rangebuf))
                return NULL;    /* fail if too long */
        strcpy (rangebuf, line);
 
index 2f2c7e2cb7ab99e84eb1d4abeb7a2900c508ff27..b3c60be9d8ff410be269472eabab35a0a0560e6f 100644 (file)
@@ -47,7 +47,7 @@ void ttytype (const char *line)
                        perror (typefile);
                return;
        }
-       while (fgets (buf, sizeof buf, fp) == buf) {
+       while (fgets(buf, sizeof(buf), fp) == buf) {
                if (strprefix(buf, "#")) {
                        continue;
                }
index 2ebdced51a0ecdcbf1a1f1ab18b7762a12e72517..78f6593cfeaf0a78f25d133631ce12df95babe74 100644 (file)
--- a/lib/tz.c
+++ b/lib/tz.c
@@ -37,7 +37,7 @@
 
        fp = fopen (fname, "r");
        if (   (NULL == fp)
-           || (fgets (tzbuf, sizeof (tzbuf), fp) == NULL)) {
+           || (fgets(tzbuf, sizeof(tzbuf), fp) == NULL)) {
                result = "TZ=CST6CDT";
        } else {
                stpsep(tzbuf, "\n");
index 8dcbd9389b9ba3d1c40855522cf477817cddb9f8..c265d49d41755084e402eb589b67ff5c76bf75dd 100644 (file)
@@ -127,7 +127,7 @@ static int check_status (const char *name, const char *sname, uid_t uid)
        if (NULL == sfile) {
                return 0;
        }
-       while (fgets (line, sizeof (line), sfile) == line) {
+       while (fgets(line, sizeof(line), sfile) == line) {
                if (strprefix(line, "Uid:\t")) {
                        unsigned long ruid, euid, suid;
 
index 297ca5c7f56ae6032807c63fe0ec7f8307f2d0bd..41746c033907d40731967f13f813340042ee7020 100644 (file)
@@ -112,7 +112,7 @@ failtmp(const char *username, const struct utmpx *failent)
         * Append the new failure record and close the log file.
         */
 
-       if (write_full(fd, failent, sizeof *failent) == -1) {
+       if (write_full(fd, failent, sizeof(*failent)) == -1) {
                goto err_write;
        }
 
@@ -306,8 +306,8 @@ prepare_utmp(const char *name, const char *line, const char *host,
                strncpy_a(utent->ut_host, hostname);
 #endif
 #if defined(HAVE_STRUCT_UTMPX_UT_SYSLEN)
-               utent->ut_syslen = MIN (strlen (hostname),
-                                       sizeof (utent->ut_host));
+               utent->ut_syslen = MIN(strlen(hostname),
+                                      sizeof(utent->ut_host));
 #endif
 #if defined(HAVE_STRUCT_UTMPX_UT_ADDR) || defined(HAVE_STRUCT_UTMPX_UT_ADDR_V6)
                if (getaddrinfo (hostname, NULL, NULL, &info) == 0) {
@@ -320,21 +320,21 @@ prepare_utmp(const char *name, const char *line, const char *host,
 # if defined(HAVE_STRUCT_UTMPX_UT_ADDR)
                                memcpy (&(utent->ut_addr),
                                        &(sa->sin_addr),
-                                       MIN (sizeof (utent->ut_addr),
-                                            sizeof (sa->sin_addr)));
+                                       MIN(sizeof(utent->ut_addr),
+                                           sizeof(sa->sin_addr)));
 # endif
 # if defined(HAVE_STRUCT_UTMPX_UT_ADDR_V6)
                                memcpy (utent->ut_addr_v6,
                                        &(sa->sin_addr),
-                                       MIN (sizeof (utent->ut_addr_v6),
-                                            sizeof (sa->sin_addr)));
+                                       MIN(sizeof(utent->ut_addr_v6),
+                                           sizeof(sa->sin_addr)));
                        } else if (info->ai_family == AF_INET6) {
                                struct sockaddr_in6 *sa =
                                        (struct sockaddr_in6 *) info->ai_addr;
                                memcpy (utent->ut_addr_v6,
                                        &(sa->sin6_addr),
-                                       MIN (sizeof (utent->ut_addr_v6),
-                                            sizeof (sa->sin6_addr)));
+                                       MIN(sizeof(utent->ut_addr_v6),
+                                           sizeof(sa->sin6_addr)));
 # endif
                        }
                        freeaddrinfo (info);
index 9855303f593ca409d817226fb84623e308dba06e..71aa1640198a82fcbdfd65d612e51262f6d34121 100644 (file)
@@ -172,12 +172,12 @@ static int new_fields (void)
        (void) puts ("");
 
        stprintf_a(buf, "%ld", mindays);
-       change_field (buf, sizeof buf, _("Minimum Password Age"));
+       change_field(buf, sizeof(buf), _("Minimum Password Age"));
        if (a2sl(&mindays, buf, NULL, 0, -1, LONG_MAX) == -1)
                return 0;
 
        stprintf_a(buf, "%ld", maxdays);
-       change_field (buf, sizeof buf, _("Maximum Password Age"));
+       change_field(buf, sizeof(buf), _("Maximum Password Age"));
        if (a2sl(&maxdays, buf, NULL, 0, -1, LONG_MAX) == -1)
                return 0;
 
@@ -186,7 +186,7 @@ static int new_fields (void)
        else
                day_to_str_a(buf, lstchgdate);
 
-       change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)"));
+       change_field(buf, sizeof(buf), _("Last Password Change (YYYY-MM-DD)"));
 
        if (streq(buf, "-1")) {
                lstchgdate = -1;
@@ -198,12 +198,12 @@ static int new_fields (void)
        }
 
        stprintf_a(buf, "%ld", warndays);
-       change_field (buf, sizeof buf, _("Password Expiration Warning"));
+       change_field(buf, sizeof(buf), _("Password Expiration Warning"));
        if (a2sl(&warndays, buf, NULL, 0, -1, LONG_MAX) == -1)
                return 0;
 
        stprintf_a(buf, "%ld", inactdays);
-       change_field (buf, sizeof buf, _("Password Inactive"));
+       change_field(buf, sizeof(buf), _("Password Inactive"));
        if (a2sl(&inactdays, buf, NULL, 0, -1, LONG_MAX) == -1)
                return 0;
 
@@ -212,7 +212,7 @@ static int new_fields (void)
        else
                day_to_str_a(buf, expdate);
 
-       change_field (buf, sizeof buf,
+       change_field(buf, sizeof(buf),
                      _("Account Expiration Date (YYYY-MM-DD)"));
 
        if (streq(buf, "-1")) {
@@ -614,7 +614,7 @@ static void update_age (/*@null@*/const struct spwd *sp,
        if (NULL == sp) {
                struct passwd pwent = *pw;
 
-               memzero (&spwent, sizeof spwent);
+               memzero(&spwent, sizeof(spwent));
                spwent.sp_namp = xstrdup (pwent.pw_name);
                spwent.sp_pwdp = xstrdup (pwent.pw_passwd);
                spwent.sp_flag = SHADOW_SP_FLAG_UNSET;
index 2fe99ac197a28d7ffba01c453e189184a392f9c2..6fd2c9f584991f289dee10428f8bdb4bb8ff4c7b 100644 (file)
@@ -180,31 +180,31 @@ static void new_fields (void)
        puts (_("Enter the new value, or press ENTER for the default"));
 
        if (may_change_field ('f')) {
-               change_field (fullnm, sizeof fullnm, _("Full Name"));
+               change_field(fullnm, sizeof(fullnm), _("Full Name"));
        } else {
                printf (_("\t%s: %s\n"), _("Full Name"), fullnm);
        }
 
        if (may_change_field ('r')) {
-               change_field (roomno, sizeof roomno, _("Room Number"));
+               change_field(roomno, sizeof(roomno), _("Room Number"));
        } else {
                printf (_("\t%s: %s\n"), _("Room Number"), roomno);
        }
 
        if (may_change_field ('w')) {
-               change_field (workph, sizeof workph, _("Work Phone"));
+               change_field(workph, sizeof(workph), _("Work Phone"));
        } else {
                printf (_("\t%s: %s\n"), _("Work Phone"), workph);
        }
 
        if (may_change_field ('h')) {
-               change_field (homeph, sizeof homeph, _("Home Phone"));
+               change_field(homeph, sizeof(homeph), _("Home Phone"));
        } else {
                printf (_("\t%s: %s\n"), _("Home Phone"), homeph);
        }
 
        if (amroot) {
-               change_field (slop, sizeof slop, _("Other"));
+               change_field(slop, sizeof(slop), _("Other"));
        }
 }
 
index 0e6f5719fb5719dc088b9b8a6b5c461260450b62..256172f490615eeae297a024b6cdd37504281708 100644 (file)
@@ -476,7 +476,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) != NULL) {
+       while (fgets(buf, (int) sizeof(buf), stdin) != NULL) {
                line++;
                if (stpsep(buf, "\n") == NULL) {
                        fprintf (stderr, _("%s: line %jd: line too long\n"),
index b67fc9f6b6e8a54a8f68a103537f6a4ce11ad7f0..16a0073715ead1e1fea2cc4b7bbd2676f6f2f33c 100644 (file)
@@ -522,14 +522,14 @@ int main (int argc, char **argv)
         * last change date is set in the age only if aging information is
         * present.
         */
-       while (fgets (buf, sizeof buf, stdin) != NULL) {
+       while (fgets(buf, sizeof(buf), stdin) != NULL) {
                char  *cp;
 
                line++;
                if (stpsep(buf, "\n") == NULL) {
                        if (feof (stdin) == 0) {
                                // Drop all remaining characters on this line.
-                               while (fgets (buf, sizeof buf, stdin) != NULL) {
+                               while (fgets(buf, sizeof(buf), stdin) != NULL) {
                                        if (strchr(buf, '\n'))
                                                break;
                                }
index ce5f5b46e3dbfed8983302ff66fc1146bc5877be..5a1729c4c087718297e831e0d802c8505cc9a825 100644 (file)
@@ -123,7 +123,7 @@ usage (int status)
 static void new_fields (void)
 {
        puts (_("Enter the new value, or press ENTER for the default"));
-       change_field (loginsh, sizeof loginsh, _("Login Shell"));
+       change_field(loginsh, sizeof(loginsh), _("Login Shell"));
 }
 
 /*
index 6bb93ae1256785c7fefa05e10006f67e3f9e9eda..2224a50d6bef7708b359221b44ad1dd04634dfd6 100644 (file)
@@ -245,7 +245,7 @@ static bool reset_one (uid_t uid)
        fl.fail_cnt = 0;
 
        if (   (fseeko (fail, offset, SEEK_SET) == 0)
-           && (fwrite (&fl, sizeof (fl), 1, fail) == 1)) {
+           && (fwrite(&fl, sizeof(fl), 1, fail) == 1)) {
                (void) fflush (fail);
                return false;
        }
@@ -266,7 +266,7 @@ static void reset (void)
                /* There is no need to reset outside of the faillog
                 * database.
                 */
-               uid_t uidmax = statbuf.st_size / sizeof (struct faillog);
+               uid_t uidmax = statbuf.st_size / sizeof(struct faillog);
                if (uidmax > 1) {
                        uidmax--;
                }
@@ -341,7 +341,7 @@ static bool setmax_one (uid_t uid, short max)
        fl.fail_max = max;
 
        if (   (fseeko (fail, offset, SEEK_SET) == 0)
-           && (fwrite (&fl, sizeof (fl), 1, fail) == 1)) {
+           && (fwrite(&fl, sizeof(fl), 1, fail) == 1)) {
                (void) fflush (fail);
                return false;
        }
@@ -372,7 +372,7 @@ static void setmax (short max)
                        /* The default umax value is based on the size of the
                         * faillog database.
                         */
-                       uid_t uidmax = statbuf.st_size / sizeof (struct faillog);
+                       uid_t uidmax = statbuf.st_size / sizeof(struct faillog);
                        if (uidmax > 1) {
                                uidmax--;
                        }
@@ -439,7 +439,7 @@ static bool set_locktime_one (uid_t uid, long locktime)
        fl.fail_locktime = locktime;
 
        if (   (fseeko (fail, offset, SEEK_SET) == 0)
-           && (fwrite (&fl, sizeof (fl), 1, fail) == 1)) {
+           && (fwrite(&fl, sizeof(fl), 1, fail) == 1)) {
                (void) fflush (fail);
                return false;
        }
@@ -470,7 +470,7 @@ static void set_locktime (long locktime)
                        /* The default umax value is based on the size of the
                         * faillog database.
                         */
-                       uid_t uidmax = statbuf.st_size / sizeof (struct faillog);
+                       uid_t uidmax = statbuf.st_size / sizeof(struct faillog);
                        if (uidmax > 1) {
                                uidmax--;
                        }
index 59819616ef2abd036ba31a6edf3028587b357f4c..228534ea5a30a7535841fbfbe775e40faa14026f 100644 (file)
@@ -148,7 +148,7 @@ static void fail_exit(int status)
  */
 static void new_grent (struct group *grent)
 {
-       memzero (grent, sizeof *grent);
+       memzero(grent, sizeof(*grent));
        grent->gr_name = group_name;
        if (pflg) {
                grent->gr_passwd = group_passwd;
@@ -168,7 +168,7 @@ static void new_grent (struct group *grent)
  */
 static void new_sgent (struct sgrp *sgent)
 {
-       memzero (sgent, sizeof *sgent);
+       memzero(sgent, sizeof(*sgent));
        sgent->sg_namp = group_name;
        if (pflg) {
                sgent->sg_passwd = group_passwd;
index a508c197fecc4653c05bfe46b9e044212c412707..9004073fcb2a49c3e615eaba9ca600369233dc69 100644 (file)
@@ -243,7 +243,7 @@ grp_update(void)
                         * shadowed password, we force the creation of a
                         * gshadow entry when a new password is requested.
                         */
-                       bzero(&sgrp, sizeof sgrp);
+                       bzero(&sgrp, sizeof(sgrp));
                        sgrp.sg_namp   = xstrdup (grp.gr_name);
                        sgrp.sg_passwd = xstrdup (grp.gr_passwd);
                        sgrp.sg_adm    = &empty;
index 201fe0621e62ef1a48c5887c3e96339b0e918d55..7cd200ef6d2e23b59d4b76d60cde6fd3a83cdb02 100644 (file)
@@ -215,7 +215,7 @@ int main (int argc, char **argv)
                        static char *empty = NULL;
 
                        /* add new shadow group entry */
-                       bzero(&sgent, sizeof sgent);
+                       bzero(&sgent, sizeof(sgent));
                        sgent.sg_namp = gr->gr_name;
                        sgent.sg_passwd = gr->gr_passwd;
                        sgent.sg_adm = &empty;
index 46ccc165e6378792309645cc3cf62d83c174ce16..747900fdb93f52891501fe54e811533ab1fd97fd 100644 (file)
@@ -119,7 +119,7 @@ static void print_one (/*@null@*/const struct passwd *pw)
                 * entered for this user, which should be able to get the
                 * empty entry in this case.
                 */
-               if (fread (&ll, sizeof (ll), 1, lastlogfile) != 1) {
+               if (fread(&ll, sizeof(ll), 1, lastlogfile) != 1) {
                        fprintf (stderr,
                                 _("%s: Failed to get the entry for UID %lu\n"),
                                 Prog, (unsigned long)pw->pw_uid);
@@ -131,7 +131,7 @@ static void print_one (/*@null@*/const struct passwd *pw)
                 * as if we were reading an non existing entry in the
                 * sparse lastlog file).
                 */
-               memzero (&ll, sizeof (ll));
+               memzero(&ll, sizeof(ll));
        }
 
        /* Filter out entries that do not match with the -t or -b options */
@@ -217,12 +217,12 @@ static void update_one (/*@null@*/const struct passwd *pw)
                return;
        }
 
-       offset = (off_t) pw->pw_uid * sizeof (ll);
+       offset = (off_t) pw->pw_uid * sizeof(ll);
        /* fseeko errors are not really relevant for us. */
        err = fseeko (lastlogfile, offset, SEEK_SET);
        assert (0 == err);
 
-       memzero (&ll, sizeof (ll));
+       memzero(&ll, sizeof(ll));
 
        if (Sflg) {
                ll.ll_time = NOW;
@@ -244,7 +244,7 @@ static void update_one (/*@null@*/const struct passwd *pw)
        }
 #endif
 
-       if (fwrite (&ll, sizeof(ll), 1, lastlogfile) != 1) {
+       if (fwrite(&ll, sizeof(ll), 1, lastlogfile) != 1) {
                        fprintf (stderr,
                                 _("%s: Failed to update the entry for UID %lu\n"),
                                 Prog, (unsigned long)pw->pw_uid);
index 03d1c92b411e9687d197a685faaabbe1d2182c57..a3ba39e17a46983ef5dde078f7287abd3fb37907 100644 (file)
@@ -643,7 +643,7 @@ int main (int argc, char **argv)
                unsigned int  failcount = 0;
 
                /* Make the login prompt look like we want it */
-               if (gethostname (hostn, sizeof (hostn)) == 0) {
+               if (gethostname(hostn, sizeof(hostn)) == 0) {
                        stprintf_a(loginprompt, _("%s login: "), hostn);
                } else {
                        strtcpy_a(loginprompt, _("login: "));
@@ -1203,7 +1203,7 @@ int main (int argc, char **argv)
 #ifdef HAVE_LL_HOST            /* __linux__ || SUN4 */
                        if (!strneq_a(ll.ll_host, "")) {
                                printf (_(" from %.*s"),
-                                       (int) sizeof ll.ll_host, ll.ll_host);
+                                       (int) sizeof(ll.ll_host), ll.ll_host);
                        }
 #endif
                        printf (".\n");
index d519772819fc3a8992e6bfec2f70e3358737e6aa..9cd147417d76c2f122bbef22a37b5adca94be2de 100644 (file)
@@ -100,7 +100,7 @@ login_access(const char *user, const char *from)
        if (NULL != fp) {
                intmax_t lineno = 0;    /* for diagnostics */
                while (   !match
-                      && (fgets (line, sizeof (line), fp) == line))
+                      && (fgets(line, sizeof(line), fp) == line))
                {
                        char  *p;
 
@@ -183,7 +183,7 @@ static char *myhostname (void)
        static char name[MAXHOSTNAMELEN + 1] = "";
 
        if (streq(name, "")) {
-               gethostname (name, sizeof (name));
+               gethostname(name, sizeof(name));
                stpcpy(&name[MAXHOSTNAMELEN], "");
        }
        return (name);
index fe2b2a9084037f308e53a68c8b5dbd8d47043953..894e68075f412802385112926a4a5b360564c1c9 100644 (file)
@@ -1109,7 +1109,7 @@ int main (int argc, char **argv)
         * over 100 is allocated. The pw_gid field will be updated with that
         * value.
         */
-       while (fgets (buf, sizeof buf, stdin) != NULL) {
+       while (fgets(buf, sizeof(buf), stdin) != NULL) {
                line++;
                if (stpsep(buf, "\n") == NULL && feof(stdin) == 0) {
                        fprintf (stderr, _("%s: line %jd: line too long\n"),
index a92b1f961217eb794e5b203d2ff5e5d5b4c0982e..38d0a0a199797d3d0d3fe83862572903a52aa2a5 100644 (file)
@@ -249,7 +249,7 @@ int main (int argc, char **argv)
                        spent = *sp;
                } else {
                        /* add new shadow entry */
-                       bzero(&spent, sizeof spent);
+                       bzero(&spent, sizeof(spent));
                        spent.sp_namp   = pw->pw_name;
                        spent.sp_min    = getdef_num ("PASS_MIN_DAYS", -1);
                        spent.sp_max    = getdef_num ("PASS_MAX_DAYS", -1);
index d3812bec646ae0a6df123eb9cec724fcd1934d4f..4b86afb3fc287373d83707afce4fcbaaed200e87 100644 (file)
@@ -73,7 +73,7 @@ check_su_auth(const char *actual_id, const char *wanted_id, bool su_to_root)
                return DENY;
        }
 
-       while (fgets (temp, sizeof (temp), authfile_fd) != NULL) {
+       while (fgets(temp, sizeof(temp), authfile_fd) != NULL) {
                char  *p;
 
                lines++;
index efc366c9da587051917463ae8b2a11b47a9c4c2d..fcf9b0d21554f59e297da49be5298bb6e14e2ce0 100644 (file)
@@ -355,7 +355,7 @@ get_defaults(struct option_flags *flags)
         * Read the file a line at a time. Only the lines that have relevant
         * values are used, everything else can be ignored.
         */
-       while (fgets (buf, sizeof buf, fp) == buf) {
+       while (fgets(buf, sizeof(buf), fp) == buf) {
                stpsep(buf, "\n");
 
                cp = stpsep(buf, "=");
@@ -587,7 +587,7 @@ set_defaults(void)
                goto skip;
        }
 
-       while (fgets (buf, sizeof buf, ifp) == buf) {
+       while (fgets(buf, sizeof(buf), ifp) == buf) {
                char  *val;
 
                if (stpsep(buf, "\n") == NULL) {
@@ -930,7 +930,7 @@ static void usage (int status)
  */
 static void new_pwent (struct passwd *pwent)
 {
-       memzero (pwent, sizeof *pwent);
+       memzero(pwent, sizeof(*pwent));
        pwent->pw_name = (char *) user_name;
        if (is_shadow_pwd) {
                pwent->pw_passwd = (char *) SHADOW_PASSWD_STRING;
@@ -953,7 +953,7 @@ static void new_pwent (struct passwd *pwent)
  */
 static void new_spent (struct spwd *spent)
 {
-       memzero (spent, sizeof *spent);
+       memzero(spent, sizeof(*spent));
        spent->sp_namp = (char *) user_name;
        spent->sp_pwdp = (char *) user_pass;
        spent->sp_lstchg = gettime () / DAY;
@@ -1855,7 +1855,7 @@ static char *empty_list = NULL;
 
 static void new_grent (struct group *grent)
 {
-       memzero (grent, sizeof *grent);
+       memzero(grent, sizeof(*grent));
        grent->gr_name = (char *) user_name;
 #ifdef  SHADOWGRP
        if (is_shadow_grp) {
@@ -1879,7 +1879,7 @@ static void new_grent (struct group *grent)
 
 static void new_sgent (struct sgrp *sgent)
 {
-       memzero (sgent, sizeof *sgent);
+       memzero(sgent, sizeof(*sgent));
        sgent->sg_namp = (char *) user_name;
        sgent->sg_passwd = "!"; /* XXX warning: const */
        sgent->sg_adm = &empty_list;
@@ -1956,14 +1956,14 @@ static void faillog_reset (uid_t uid)
 {
        struct faillog fl;
        int fd;
-       off_t offset_uid = (off_t) (sizeof fl) * uid;
+       off_t offset_uid = (off_t) sizeof(fl) * uid;
        struct stat st;
 
        if (stat (FAILLOG_FILE, &st) != 0 || st.st_size <= offset_uid) {
                return;
        }
 
-       memzero (&fl, sizeof (fl));
+       memzero(&fl, sizeof(fl));
 
        fd = open (FAILLOG_FILE, O_RDWR);
        if (-1 == fd) {
@@ -1974,7 +1974,7 @@ static void faillog_reset (uid_t uid)
                return;
        }
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
-           || (write_full(fd, &fl, sizeof (fl)) == -1)
+           || (write_full(fd, &fl, sizeof(fl)) == -1)
            || (fsync (fd) != 0)) {
                fprintf (stderr,
                         _("%s: failed to reset the faillog entry of UID %lu: %s\n"),
@@ -1994,7 +1994,7 @@ static void lastlog_reset (uid_t uid)
 {
        struct lastlog ll;
        int fd;
-       off_t offset_uid = (off_t) (sizeof ll) * uid;
+       off_t offset_uid = (off_t) sizeof(ll) * uid;
        uid_t max_uid;
        struct stat st;
 
@@ -2008,7 +2008,7 @@ static void lastlog_reset (uid_t uid)
                return;
        }
 
-       memzero (&ll, sizeof (ll));
+       memzero(&ll, sizeof(ll));
 
        fd = open(_PATH_LASTLOG, O_RDWR);
        if (-1 == fd) {
@@ -2019,7 +2019,7 @@ static void lastlog_reset (uid_t uid)
                return;
        }
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
-           || (write_full (fd, &ll, sizeof (ll)) == -1)
+           || (write_full(fd, &ll, sizeof(ll)) == -1)
            || (fsync (fd) != 0)) {
                fprintf (stderr,
                         _("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
index 938941c6205746a4c9ef0cd87c5192cd79ae6aeb..a77344e8f99fd8947ecfea7d6df8b722ab739ae0 100644 (file)
@@ -1720,7 +1720,7 @@ static void usr_update (struct option_flags *flags)
                         *    a shadowed password
                         *  + aging information is requested
                         */
-                       bzero(&spent, sizeof spent);
+                       bzero(&spent, sizeof(spent));
                        spent.sp_namp   = user_name;
 
                        /* The user explicitly asked for a shadow feature.
@@ -1897,8 +1897,8 @@ static void update_lastlog (void)
 {
        struct lastlog ll;
        int fd;
-       off_t off_uid = (off_t) user_id * sizeof ll;
-       off_t off_newuid = (off_t) user_newid * sizeof ll;
+       off_t off_uid = (off_t) user_id * sizeof(ll);
+       off_t off_newuid = (off_t) user_newid * sizeof(ll);
        uid_t max_uid;
 
        if (access(_PATH_LASTLOG, F_OK) != 0) {
@@ -1921,10 +1921,10 @@ static void update_lastlog (void)
        }
 
        if (   (lseek (fd, off_uid, SEEK_SET) == off_uid)
-           && (read (fd, &ll, sizeof ll) == (ssize_t) sizeof ll)) {
+           && (read(fd, &ll, sizeof(ll)) == (ssize_t) sizeof(ll))) {
                /* Copy the old entry to its new location */
                if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
-                   || (write_full(fd, &ll, sizeof ll) == -1)
+                   || (write_full(fd, &ll, sizeof(ll)) == -1)
                    || (fsync (fd) != 0)) {
                        fprintf (stderr,
                                 _("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
@@ -1936,11 +1936,11 @@ static void update_lastlog (void)
 
                /* Check if the new UID already has an entry */
                if (   (lseek (fd, off_newuid, SEEK_SET) == off_newuid)
-                   && (read (fd, &ll, sizeof ll) == (ssize_t) sizeof ll)) {
+                   && (read(fd, &ll, sizeof(ll)) == (ssize_t) sizeof(ll))) {
                        /* Reset the new uid's lastlog entry */
-                       memzero (&ll, sizeof (ll));
+                       memzero(&ll, sizeof(ll));
                        if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
-                           || (write_full(fd, &ll, sizeof ll) == -1)
+                           || (write_full(fd, &ll, sizeof(ll)) == -1)
                            || (fsync (fd) != 0)) {
                                fprintf (stderr,
                                         _("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
@@ -1968,8 +1968,8 @@ static void update_faillog (void)
 {
        struct faillog fl;
        int fd;
-       off_t off_uid = (off_t) user_id * sizeof fl;
-       off_t off_newuid = (off_t) user_newid * sizeof fl;
+       off_t off_uid = (off_t) user_id * sizeof(fl);
+       off_t off_newuid = (off_t) user_newid * sizeof(fl);
 
        if (access (FAILLOG_FILE, F_OK) != 0) {
                return;
@@ -1985,10 +1985,10 @@ static void update_faillog (void)
        }
 
        if (   (lseek (fd, off_uid, SEEK_SET) == off_uid)
-           && (read (fd, &fl, sizeof fl) == (ssize_t) sizeof fl)) {
+           && (read(fd, &fl, sizeof(fl)) == (ssize_t) sizeof(fl))) {
                /* Copy the old entry to its new location */
                if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
-                   || (write_full(fd, &fl, sizeof fl) == -1)
+                   || (write_full(fd, &fl, sizeof(fl)) == -1)
                    || (fsync (fd) != 0)) {
                        fprintf (stderr,
                                 _("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
@@ -2000,11 +2000,11 @@ static void update_faillog (void)
 
                /* Check if the new UID already has an entry */
                if (   (lseek (fd, off_newuid, SEEK_SET) == off_newuid)
-                   && (read (fd, &fl, sizeof fl) == (ssize_t) sizeof fl)) {
+                   && (read(fd, &fl, sizeof(fl)) == (ssize_t) sizeof(fl))) {
                        /* Reset the new uid's faillog entry */
-                       memzero (&fl, sizeof (fl));
+                       memzero(&fl, sizeof(fl));
                        if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
-                           || (write_full(fd, &fl, sizeof fl) == -1))
+                           || (write_full(fd, &fl, sizeof(fl)) == -1))
                        {
                                fprintf (stderr,
                                         _("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),