Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): remove redundant parentheses from size...



details:   https://anonhg.NetBSD.org/src/rev/dc6583642efd
branches:  trunk
changeset: 942076:dc6583642efd
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Nov 05 17:27:16 2020 +0000

description:
make(1): remove redundant parentheses from sizeof operator

The parentheses are only needed if the argument is a type, not an
expression.

diffstat:

 usr.bin/make/arch.c                   |  56 ++++++++++++++++----------------
 usr.bin/make/cond.c                   |   8 ++--
 usr.bin/make/dir.c                    |  12 +++---
 usr.bin/make/filemon/filemon_dev.c    |   4 +-
 usr.bin/make/filemon/filemon_ktrace.c |   4 +-
 usr.bin/make/hash.c                   |  10 +++---
 usr.bin/make/job.c                    |  16 ++++----
 usr.bin/make/main.c                   |  26 +++++++-------
 usr.bin/make/meta.c                   |  58 +++++++++++++++++-----------------
 usr.bin/make/parse.c                  |   8 ++--
 usr.bin/make/suff.c                   |   6 +-
 usr.bin/make/targ.c                   |   6 +-
 usr.bin/make/util.c                   |   6 +-
 usr.bin/make/var.c                    |  18 +++++-----
 14 files changed, 119 insertions(+), 119 deletions(-)

diffs (truncated from 867 to 300 lines):

diff -r 3a4571ea6986 -r dc6583642efd usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Thu Nov 05 16:06:41 2020 +0000
+++ b/usr.bin/make/arch.c       Thu Nov 05 17:27:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.153 2020/11/02 19:07:09 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.154 2020/11/05 17:27:16 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.153 2020/11/02 19:07:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.154 2020/11/05 17:27:16 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -414,7 +414,7 @@
 static struct ar_hdr *
 ArchStatMember(const char *archive, const char *member, Boolean hash)
 {
-#define AR_MAX_NAME_LEN (sizeof(arh.ar_name) - 1)
+#define AR_MAX_NAME_LEN (sizeof arh.ar_name - 1)
     FILE *arch;                        /* Stream to archive */
     size_t size;               /* Size of archive member */
     char magic[SARMAG];
@@ -496,15 +496,15 @@
        return NULL;
     }
 
-    ar = bmake_malloc(sizeof(Arch));
+    ar = bmake_malloc(sizeof *ar);
     ar->name = bmake_strdup(archive);
     ar->fnametab = NULL;
     ar->fnamesize = 0;
     HashTable_Init(&ar->members);
     memName[AR_MAX_NAME_LEN] = '\0';
 
-    while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
-       if (strncmp(arh.ar_fmag, ARFMAG, sizeof(arh.ar_fmag)) != 0) {
+    while (fread(&arh, sizeof arh, 1, arch) == 1) {
+       if (strncmp(arh.ar_fmag, ARFMAG, sizeof arh.ar_fmag) != 0) {
            /*
             * The header is bogus, so the archive is bad
             * and there's no way we can recover...
@@ -519,10 +519,10 @@
             * boundary, so we need to extract the size of the file from the
             * 'size' field of the header and round it up during the seek.
             */
-           arh.ar_size[sizeof(arh.ar_size) - 1] = '\0';
+           arh.ar_size[sizeof arh.ar_size - 1] = '\0';
            size = (size_t)strtol(arh.ar_size, NULL, 10);
 
-           memcpy(memName, arh.ar_name, sizeof(arh.ar_name));
+           memcpy(memName, arh.ar_name, sizeof arh.ar_name);
            nameend = memName + AR_MAX_NAME_LEN;
            while (*nameend == ' ') {
                nameend--;
@@ -556,10 +556,10 @@
             * BSD 4.4 extended AR format: #1/<namelen>, with name as the
             * first <namelen> bytes of the file
             */
-           if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 &&
-               ch_isdigit(memName[sizeof(AR_EFMT1) - 1])) {
+           if (strncmp(memName, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 &&
+               ch_isdigit(memName[sizeof AR_EFMT1 - 1])) {
 
-               int elen = atoi(&memName[sizeof(AR_EFMT1) - 1]);
+               int elen = atoi(memName + sizeof AR_EFMT1 - 1);
 
                if ((unsigned int)elen > MAXPATHLEN)
                    goto badarch;
@@ -578,8 +578,8 @@
            {
                HashEntry *he;
                he = HashTable_CreateEntry(&ar->members, memName, NULL);
-               HashEntry_Set(he, bmake_malloc(sizeof(struct ar_hdr)));
-               memcpy(HashEntry_Get(he), &arh, sizeof(struct ar_hdr));
+               HashEntry_Set(he, bmake_malloc(sizeof arh));
+               memcpy(HashEntry_Get(he), &arh, sizeof arh);
            }
        }
        if (fseek(arch, ((long)size + 1) & ~1, SEEK_CUR) != 0)
@@ -630,8 +630,8 @@
     size_t entry;
     char *ptr, *eptr;
 
-    if (strncmp(name, ARLONGNAMES1, sizeof(ARLONGNAMES1) - 1) == 0 ||
-       strncmp(name, ARLONGNAMES2, sizeof(ARLONGNAMES2) - 1) == 0) {
+    if (strncmp(name, ARLONGNAMES1, sizeof ARLONGNAMES1 - 1) == 0 ||
+       strncmp(name, ARLONGNAMES2, sizeof ARLONGNAMES2 - 1) == 0) {
 
        if (ar->fnametab != NULL) {
            DEBUG0(ARCH, "Attempted to redefine an SVR4 name table\n");
@@ -736,13 +736,13 @@
        member = lastSlash + 1;
 
     len = tlen = strlen(member);
-    if (len > sizeof(out_arh->ar_name)) {
-       tlen = sizeof(out_arh->ar_name);
+    if (len > sizeof out_arh->ar_name) {
+       tlen = sizeof out_arh->ar_name;
     }
 
-    while (fread((char *)out_arh, sizeof(struct ar_hdr), 1, arch) == 1) {
+    while (fread(out_arh, sizeof *out_arh, 1, arch) == 1) {
 
-       if (strncmp(out_arh->ar_fmag, ARFMAG, sizeof(out_arh->ar_fmag)) != 0) {
+       if (strncmp(out_arh->ar_fmag, ARFMAG, sizeof out_arh->ar_fmag) != 0) {
            /*
             * The header is bogus, so the archive is bad
             * and there's no way we can recover...
@@ -770,7 +770,7 @@
             * the file at the actual member, rather than its header, but
             * not here...
             */
-           if (fseek(arch, -(long)sizeof(struct ar_hdr), SEEK_CUR) != 0) {
+           if (fseek(arch, -(long)sizeof *out_arh, SEEK_CUR) != 0) {
                fclose(arch);
                return NULL;
            }
@@ -782,10 +782,10 @@
         * BSD 4.4 extended AR format: #1/<namelen>, with name as the
         * first <namelen> bytes of the file
         */
-       if (strncmp(out_arh->ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 &&
-           ch_isdigit(out_arh->ar_name[sizeof(AR_EFMT1) - 1]))
+       if (strncmp(out_arh->ar_name, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 &&
+           ch_isdigit(out_arh->ar_name[sizeof AR_EFMT1 - 1]))
        {
-           int elen = atoi(&out_arh->ar_name[sizeof(AR_EFMT1) - 1]);
+           int elen = atoi(&out_arh->ar_name[sizeof AR_EFMT1 - 1]);
            char ename[MAXPATHLEN + 1];
 
            if ((unsigned int)elen > MAXPATHLEN) {
@@ -824,7 +824,7 @@
         * extract the size of the file from the 'size' field of the
         * header and round it up during the seek.
         */
-       out_arh->ar_size[sizeof(out_arh->ar_size) - 1] = '\0';
+       out_arh->ar_size[sizeof out_arh->ar_size - 1] = '\0';
        size = (int)strtol(out_arh->ar_size, NULL, 10);
        if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) {
            fclose(arch);
@@ -864,10 +864,10 @@
     arch = ArchFindMember(GNode_VarArchive(gn), GNode_VarMember(gn),
                          &arh, "r+");
 
-    snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long)now);
+    snprintf(arh.ar_date, sizeof arh.ar_date, "%-12ld", (long)now);
 
     if (arch != NULL) {
-       (void)fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);
+       (void)fwrite(&arh, sizeof arh, 1, arch);
        fclose(arch);
     }
 }
@@ -890,10 +890,10 @@
     struct utimbuf  times;     /* Times for utime() call */
 
     arch = ArchFindMember(gn->path, RANLIBMAG, &arh, "r+");
-    snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
+    snprintf(arh.ar_date, sizeof arh.ar_date, "%-12ld", (long) now);
 
     if (arch != NULL) {
-       (void)fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);
+       (void)fwrite(&arh, sizeof arh, 1, arch);
        fclose(arch);
 
        times.actime = times.modtime = now;
diff -r 3a4571ea6986 -r dc6583642efd usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Thu Nov 05 16:06:41 2020 +0000
+++ b/usr.bin/make/cond.c       Thu Nov 05 17:27:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.174 2020/11/02 19:07:09 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.175 2020/11/05 17:27:16 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.174 2020/11/02 19:07:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.175 2020/11/05 17:27:16 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -1082,7 +1082,7 @@
     enum if_states state;
 
     if (!cond_state) {
-       cond_state = bmake_malloc(max_if_depth * sizeof(*cond_state));
+       cond_state = bmake_malloc(max_if_depth * sizeof *cond_state);
        cond_state[0] = IF_ACTIVE;
     }
     /* skip leading character (the '.') and any whitespace */
@@ -1183,7 +1183,7 @@
             */
            max_if_depth += MAXIF_BUMP;
            cond_state = bmake_realloc(cond_state,
-                                      max_if_depth * sizeof(*cond_state));
+                                      max_if_depth * sizeof *cond_state);
        }
        state = cond_state[cond_depth];
        cond_depth++;
diff -r 3a4571ea6986 -r dc6583642efd usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Thu Nov 05 16:06:41 2020 +0000
+++ b/usr.bin/make/dir.c        Thu Nov 05 17:27:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.193 2020/10/31 17:39:20 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.194 2020/11/05 17:27:16 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -134,7 +134,7 @@
 #include "job.h"
 
 /*     "@(#)dir.c      8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: dir.c,v 1.193 2020/10/31 17:39:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.194 2020/11/05 17:27:16 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -358,8 +358,8 @@
     if (entry == NULL)
        entry = HashTable_CreateEntry(htp, pathname, NULL);
     if (HashEntry_Get(entry) == NULL) {
-       HashEntry_Set(entry, bmake_malloc(sizeof(*cst)));
-       memset(HashEntry_Get(entry), 0, sizeof(*cst));
+       HashEntry_Set(entry, bmake_malloc(sizeof *cst));
+       memset(HashEntry_Get(entry), 0, sizeof *cst);
     }
     cst = HashEntry_Get(entry);
     if (flags & CST_LSTAT) {
@@ -401,7 +401,7 @@
 {
     Dir_InitCur(cdname);
 
-    dotLast = bmake_malloc(sizeof(CachedDir));
+    dotLast = bmake_malloc(sizeof *dotLast);
     dotLast->refCount = 1;
     dotLast->hits = 0;
     dotLast->name = bmake_strdup(".DOTLAST");
@@ -1410,7 +1410,7 @@
     DIR_DEBUG1("Caching %s ...", name);
 
     if ((d = opendir(name)) != NULL) {
-       dir = bmake_malloc(sizeof(CachedDir));
+       dir = bmake_malloc(sizeof *dir);
        dir->name = bmake_strdup(name);
        dir->hits = 0;
        dir->refCount = 1;
diff -r 3a4571ea6986 -r dc6583642efd usr.bin/make/filemon/filemon_dev.c
--- a/usr.bin/make/filemon/filemon_dev.c        Thu Nov 05 16:06:41 2020 +0000
+++ b/usr.bin/make/filemon/filemon_dev.c        Thu Nov 05 17:27:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filemon_dev.c,v 1.3 2020/07/10 15:53:30 sjg Exp $      */
+/*     $NetBSD: filemon_dev.c,v 1.4 2020/11/05 17:27:16 rillig Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
        int error;
 
        /* Allocate and zero a struct filemon object.  */
-       F = calloc(1, sizeof(*F));
+       F = calloc(1, sizeof *F);
        if (F == NULL)
                return NULL;
 
diff -r 3a4571ea6986 -r dc6583642efd usr.bin/make/filemon/filemon_ktrace.c
--- a/usr.bin/make/filemon/filemon_ktrace.c     Thu Nov 05 16:06:41 2020 +0000
+++ b/usr.bin/make/filemon/filemon_ktrace.c     Thu Nov 05 17:27:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filemon_ktrace.c,v 1.3 2020/10/18 11:54:43 rillig Exp $        */
+/*     $NetBSD: filemon_ktrace.c,v 1.4 2020/11/05 17:27:16 rillig Exp $        */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -198,7 +198,7 @@
        int error;
 
        /* Allocate and zero a struct filemon object.  */
-       F = calloc(1, sizeof(*F));
+       F = calloc(1, sizeof *F);
        if (F == NULL)
                return NULL;
 
diff -r 3a4571ea6986 -r dc6583642efd usr.bin/make/hash.c
--- a/usr.bin/make/hash.c       Thu Nov 05 16:06:41 2020 +0000
+++ b/usr.bin/make/hash.c       Thu Nov 05 17:27:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.55 2020/10/25 19:28:44 rillig Exp $ */
+/*     $NetBSD: hash.c,v 1.56 2020/11/05 17:27:16 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@



Home | Main Index | Thread Index | Old Index