Module Name:    src
Committed By:   rillig
Date:           Thu Nov  5 17:27:16 UTC 2020

Modified Files:
        src/usr.bin/make: arch.c cond.c dir.c hash.c job.c main.c meta.c
            parse.c suff.c targ.c util.c var.c
        src/usr.bin/make/filemon: filemon_dev.c filemon_ktrace.c

Log Message:
make(1): remove redundant parentheses from sizeof operator

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


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/usr.bin/make/arch.c
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/make/cond.c
cvs rdiff -u -r1.193 -r1.194 src/usr.bin/make/dir.c
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/make/hash.c
cvs rdiff -u -r1.302 -r1.303 src/usr.bin/make/job.c
cvs rdiff -u -r1.425 -r1.426 src/usr.bin/make/main.c
cvs rdiff -u -r1.137 -r1.138 src/usr.bin/make/meta.c
cvs rdiff -u -r1.426 -r1.427 src/usr.bin/make/parse.c
cvs rdiff -u -r1.230 -r1.231 src/usr.bin/make/suff.c
cvs rdiff -u -r1.126 -r1.127 src/usr.bin/make/targ.c
cvs rdiff -u -r1.64 -r1.65 src/usr.bin/make/util.c
cvs rdiff -u -r1.658 -r1.659 src/usr.bin/make/var.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/filemon/filemon_dev.c \
    src/usr.bin/make/filemon/filemon_ktrace.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.153 src/usr.bin/make/arch.c:1.154
--- src/usr.bin/make/arch.c:1.153	Mon Nov  2 19:07:09 2020
+++ src/usr.bin/make/arch.c	Thu Nov  5 17:27:16 2020
@@ -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 @@ Arch_ParseArchive(char **pp, GNodeList *
 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 @@ ArchStatMember(const char *archive, cons
 	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 @@ ArchStatMember(const char *archive, cons
 	     * 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 @@ ArchStatMember(const char *archive, cons
 	     * 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 @@ ArchStatMember(const char *archive, cons
 	    {
 		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 @@ ArchSVR4Entry(Arch *ar, char *name, size
     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 @@ ArchFindMember(const char *archive, cons
 	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 @@ ArchFindMember(const char *archive, cons
 	     * 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 @@ ArchFindMember(const char *archive, cons
 	 * 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 @@ skip:
 	 * 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_Touch(GNode *gn)
     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 @@ Arch_TouchLib(GNode *gn)
     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;

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.174 src/usr.bin/make/cond.c:1.175
--- src/usr.bin/make/cond.c:1.174	Mon Nov  2 19:07:09 2020
+++ src/usr.bin/make/cond.c	Thu Nov  5 17:27:16 2020
@@ -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 @@ Cond_EvalLine(const char *line)
     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 @@ Cond_EvalLine(const char *line)
 	     */
 	    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++;

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.193 src/usr.bin/make/dir.c:1.194
--- src/usr.bin/make/dir.c:1.193	Sat Oct 31 17:39:20 2020
+++ src/usr.bin/make/dir.c	Thu Nov  5 17:27:16 2020
@@ -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 @@ cached_stats(HashTable *htp, const char 
     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_InitDir(const char *cdname)
 {
     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_AddDir(SearchPath *path, const char 
     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;

Index: src/usr.bin/make/hash.c
diff -u src/usr.bin/make/hash.c:1.55 src/usr.bin/make/hash.c:1.56
--- src/usr.bin/make/hash.c:1.55	Sun Oct 25 19:28:44 2020
+++ src/usr.bin/make/hash.c	Thu Nov  5 17:27:16 2020
@@ -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 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.55 2020/10/25 19:28:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.56 2020/11/05 17:27:16 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -128,7 +128,7 @@ void
 HashTable_Init(HashTable *t)
 {
 	unsigned int n = 16, i;
-	HashEntry **buckets = bmake_malloc(sizeof(*buckets) * n);
+	HashEntry **buckets = bmake_malloc(sizeof *buckets * n);
 	for (i = 0; i < n; i++)
 		buckets[i] = NULL;
 
@@ -195,7 +195,7 @@ HashTable_Enlarge(HashTable *t)
 	HashEntry **oldBuckets = t->buckets;
 	unsigned int newSize = 2 * oldSize;
 	unsigned int newMask = newSize - 1;
-	HashEntry **newBuckets = bmake_malloc(sizeof(*newBuckets) * newSize);
+	HashEntry **newBuckets = bmake_malloc(sizeof *newBuckets * newSize);
 	size_t i;
 
 	for (i = 0; i < newSize; i++)
@@ -239,7 +239,7 @@ HashTable_CreateEntry(HashTable *t, cons
 	if (t->numEntries >= rebuildLimit * t->bucketsSize)
 		HashTable_Enlarge(t);
 
-	he = bmake_malloc(sizeof(*he) + keylen);
+	he = bmake_malloc(sizeof *he + keylen);
 	he->value = NULL;
 	he->key_hash = h;
 	memcpy(he->key, key, keylen + 1);

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.302 src/usr.bin/make/job.c:1.303
--- src/usr.bin/make/job.c:1.302	Sun Nov  1 18:45:49 2020
+++ src/usr.bin/make/job.c	Thu Nov  5 17:27:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.302 2020/11/01 18:45:49 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.303 2020/11/05 17:27:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.302 2020/11/01 18:45:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.303 2020/11/05 17:27:16 rillig Exp $");
 
 /* A shell defines how the commands are run.  All commands for a target are
  * written into a single file, which is then given to the shell to execute
@@ -1442,7 +1442,7 @@ JobMakeArgv(Job *job, char **argv)
 	 * Bourne shell thinks its second argument is a file to source.
 	 * Grrrr. Note the ten-character limitation on the combined arguments.
 	 */
-	(void)snprintf(args, sizeof(args), "-%s%s",
+	(void)snprintf(args, sizeof args, "-%s%s",
 		      ((job->flags & JOB_IGNERR) ? "" :
 		       (commandShell->exit ? commandShell->exit : "")),
 		      ((job->flags & JOB_SILENT) ? "" :
@@ -2164,9 +2164,9 @@ Job_Init(void)
     JobCreatePipe(&childExitJob, 3);
 
     /* Preallocate enough for the maximum number of jobs.  */
-    fds = bmake_malloc(sizeof(*fds) *
+    fds = bmake_malloc(sizeof *fds *
 	(npseudojobs + (size_t)opts.maxJobs) * nfds_per_job());
-    jobfds = bmake_malloc(sizeof(*jobfds) *
+    jobfds = bmake_malloc(sizeof *jobfds *
 	(npseudojobs + (size_t)opts.maxJobs) * nfds_per_job());
 
     /* These are permanent entries and take slots 0 and 1 */
@@ -2311,7 +2311,7 @@ Job_ParseShell(char *line)
 
     free(shellArgv);
 
-    memset(&newShell, 0, sizeof(newShell));
+    memset(&newShell, 0, sizeof newShell);
 
     /*
      * Parse the specification by keyword
@@ -2423,7 +2423,7 @@ Job_ParseShell(char *line)
 	    }
 	    commandShell = sh;
 	} else {
-	    commandShell = bmake_malloc(sizeof(Shell));
+	    commandShell = bmake_malloc(sizeof *commandShell);
 	    *commandShell = newShell;
 	}
 	/* this will take care of shellErrFlag */
@@ -2699,7 +2699,7 @@ Job_ServerStart(int max_tokens, int jp_0
 
     JobCreatePipe(&tokenWaitJob, 15);
 
-    snprintf(jobarg, sizeof(jobarg), "%d,%d",
+    snprintf(jobarg, sizeof jobarg, "%d,%d",
 	    tokenWaitJob.inPipe, tokenWaitJob.outPipe);
 
     Var_Append(MAKEFLAGS, "-J", VAR_GLOBAL);

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.425 src/usr.bin/make/main.c:1.426
--- src/usr.bin/make/main.c:1.425	Wed Nov  4 13:29:42 2020
+++ src/usr.bin/make/main.c	Thu Nov  5 17:27:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.425 2020/11/04 13:29:42 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.426 2020/11/05 17:27:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.425 2020/11/04 13:29:42 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.426 2020/11/05 17:27:16 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -799,9 +799,9 @@ siginfo(int signo MAKE_ATTR_UNUSED)
 	char dir[MAXPATHLEN];
 	char str[2 * MAXPATHLEN];
 	int len;
-	if (getcwd(dir, sizeof(dir)) == NULL)
+	if (getcwd(dir, sizeof dir) == NULL)
 		return;
-	len = snprintf(str, sizeof(str), "%s: Working in: %s\n", progname, dir);
+	len = snprintf(str, sizeof str, "%s: Working in: %s\n", progname, dir);
 	if (len > 0)
 		(void)write(STDERR_FILENO, str, (size_t)len);
 }
@@ -984,9 +984,9 @@ init_machine_arch(void)
 #ifdef MAKE_NATIVE
 	{
 		struct utsname utsname;
-		static char machine_arch_buf[sizeof(utsname.machine)];
+		static char machine_arch_buf[sizeof utsname.machine];
 		const int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
-		size_t len = sizeof(machine_arch_buf);
+		size_t len = sizeof machine_arch_buf;
 
 		if (sysctl(mib, __arraycount(mib), machine_arch_buf,
 			&len, NULL, 0) < 0) {
@@ -1435,16 +1435,16 @@ main(int argc, char **argv)
 	    makelevel = ((ep = getenv(MAKE_LEVEL_ENV)) && *ep) ? atoi(ep) : 0;
 	    if (makelevel < 0)
 		makelevel = 0;
-	    snprintf(tmp, sizeof(tmp), "%d", makelevel);
+	    snprintf(tmp, sizeof tmp, "%d", makelevel);
 	    Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL);
-	    snprintf(tmp, sizeof(tmp), "%u", myPid);
+	    snprintf(tmp, sizeof tmp, "%u", myPid);
 	    Var_Set(".MAKE.PID", tmp, VAR_GLOBAL);
-	    snprintf(tmp, sizeof(tmp), "%u", getppid());
+	    snprintf(tmp, sizeof tmp, "%u", getppid());
 	    Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL);
 	}
 	if (makelevel > 0) {
 		char pn[1024];
-		snprintf(pn, sizeof(pn), "%s[%d]", progname, makelevel);
+		snprintf(pn, sizeof pn, "%s[%d]", progname, makelevel);
 		progname = bmake_strdup(pn);
 	}
 
@@ -1755,7 +1755,7 @@ Cmd_Exec(const char *cmd, const char **e
 
 	do {
 	    char   result[BUFSIZ];
-	    bytes_read = read(fds[0], result, sizeof(result));
+	    bytes_read = read(fds[0], result, sizeof result);
 	    if (bytes_read > 0)
 		Buf_AddBytes(&buf, result, (size_t)bytes_read);
 	}
@@ -2186,9 +2186,9 @@ mkTempFile(const char *pattern, char **o
     if (tmpdir == NULL)
 	tmpdir = getTmpdir();
     if (pattern[0] == '/') {
-	snprintf(tfile, sizeof(tfile), "%s", pattern);
+	snprintf(tfile, sizeof tfile, "%s", pattern);
     } else {
-	snprintf(tfile, sizeof(tfile), "%s%s", tmpdir, pattern);
+	snprintf(tfile, sizeof tfile, "%s%s", tmpdir, pattern);
     }
     if ((fd = mkstemp(tfile)) < 0)
 	Punt("Could not create temporary file %s: %s", tfile, strerror(errno));

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.137 src/usr.bin/make/meta.c:1.138
--- src/usr.bin/make/meta.c:1.137	Wed Nov  4 13:27:00 2020
+++ src/usr.bin/make/meta.c	Thu Nov  5 17:27:16 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.137 2020/11/04 13:27:00 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.138 2020/11/05 17:27:16 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -179,7 +179,7 @@ filemon_read(FILE *mfp, int fd)
 	error = 0;
 	fprintf(mfp, "\n-- filemon acquired metadata --\n");
 
-	while ((n = read(fd, buf, sizeof(buf))) > 0) {
+	while ((n = read(fd, buf, sizeof buf)) > 0) {
 	    if ((ssize_t)fwrite(buf, 1, (size_t)n, mfp) < n)
 		error = EIO;
 	}
@@ -271,12 +271,12 @@ meta_name(char *mname, size_t mnamelen,
 	     * next time through.
 	     */
 	    if (tname[0] == '/') {
-		strlcpy(buf, tname, sizeof(buf));
+		strlcpy(buf, tname, sizeof buf);
 	    } else {
-		snprintf(buf, sizeof(buf), "%s/%s", cwd, tname);
+		snprintf(buf, sizeof buf, "%s/%s", cwd, tname);
 	    }
-	    eat_dots(buf, sizeof(buf), 1);	/* ./ */
-	    eat_dots(buf, sizeof(buf), 2);	/* ../ */
+	    eat_dots(buf, sizeof buf, 1);	/* ./ */
+	    eat_dots(buf, sizeof buf, 2);	/* ../ */
 	    tname = buf;
 	}
     }
@@ -508,7 +508,7 @@ meta_create(BuildMon *pbm, GNode *gn)
 	/* Don't create meta data. */
 	goto out;
 
-    fname = meta_name(pbm->meta_fname, sizeof(pbm->meta_fname),
+    fname = meta_name(pbm->meta_fname, sizeof pbm->meta_fname,
 		      dname, tname, objdir);
 
 #ifdef DEBUG_META_MODE
@@ -524,7 +524,7 @@ meta_create(BuildMon *pbm, GNode *gn)
 
     printCMDs(gn, &mf);
 
-    fprintf(mf.fp, "CWD %s\n", getcwd(buf, sizeof(buf)));
+    fprintf(mf.fp, "CWD %s\n", getcwd(buf, sizeof buf));
     fprintf(mf.fp, "TARGET %s\n", tname);
     cp = GNode_VarOodate(gn);
     if (cp && *cp) {
@@ -580,7 +580,7 @@ meta_init(void)
 
 #define get_mode_bf(bf, token) \
     if ((cp = strstr(make_mode, token))) \
-	bf = boolValue(&cp[sizeof(token) - 1])
+	bf = boolValue(cp + sizeof (token) - 1)
 
 /*
  * Initialization we need after reading makefiles.
@@ -625,7 +625,7 @@ meta_mode_init(const char *make_mode)
     if (once)
 	return;
     once = 1;
-    memset(&Mybm, 0, sizeof(Mybm));
+    memset(&Mybm, 0, sizeof Mybm);
     /*
      * We consider ourselves master of all within ${.MAKE.META.BAILIWICK}
      */
@@ -793,7 +793,7 @@ meta_job_error(Job *job, GNode *gn, int 
     if (gn) {
 	Var_Set(".ERROR_TARGET", GNode_Path(gn), VAR_GLOBAL);
     }
-    getcwd(cwd, sizeof(cwd));
+    getcwd(cwd, sizeof cwd);
     Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL);
     if (pbm->meta_fname[0]) {
 	Var_Set(".ERROR_META_FILE", pbm->meta_fname, VAR_GLOBAL);
@@ -1007,7 +1007,7 @@ meta_ignore(GNode *gn, const char *p)
 	char *fm;
 
 	/* skip if filter result is empty */
-	snprintf(fname, sizeof(fname),
+	snprintf(fname, sizeof fname,
 		 "${%s:L:${%s:ts:}}",
 		 p, MAKE_META_IGNORE_FILTER);
 	(void)Var_Subst(fname, gn, VARE_WANTRES, &fm);
@@ -1109,7 +1109,7 @@ meta_oodate(GNode *gn, Boolean oodate)
      */
     Make_DoAllVar(gn);
 
-    meta_name(fname, sizeof(fname), dname, tname, dname);
+    meta_name(fname, sizeof fname, dname, tname, dname);
 
 #ifdef DEBUG_META_MODE
     DEBUG1(META, "meta_oodate: %s\n", fname);
@@ -1131,12 +1131,12 @@ meta_oodate(GNode *gn, Boolean oodate)
 	}
 
 	if (!cwdlen) {
-	    if (getcwd(cwd, sizeof(cwd)) == NULL)
+	    if (getcwd(cwd, sizeof cwd) == NULL)
 		err(1, "Could not get current working directory");
 	    cwdlen = strlen(cwd);
 	}
-	strlcpy(lcwd, cwd, sizeof(lcwd));
-	strlcpy(latestdir, cwd, sizeof(latestdir));
+	strlcpy(lcwd, cwd, sizeof lcwd);
+	strlcpy(latestdir, cwd, sizeof latestdir);
 
 	if (!tmpdir) {
 	    tmpdir = getTmpdir();
@@ -1223,17 +1223,17 @@ meta_oodate(GNode *gn, Boolean oodate)
 			    Var_Set(lcwd_vname, lcwd, VAR_GLOBAL);
 			    Var_Set(ldir_vname, latestdir, VAR_GLOBAL);
 			}
-			snprintf(lcwd_vname, sizeof(lcwd_vname), LCWD_VNAME_FMT, pid);
-			snprintf(ldir_vname, sizeof(ldir_vname), LDIR_VNAME_FMT, pid);
+			snprintf(lcwd_vname, sizeof lcwd_vname, LCWD_VNAME_FMT, pid);
+			snprintf(ldir_vname, sizeof ldir_vname, LDIR_VNAME_FMT, pid);
 			lastpid = pid;
 			ldir = Var_Value(ldir_vname, VAR_GLOBAL, &tp);
 			if (ldir) {
-			    strlcpy(latestdir, ldir, sizeof(latestdir));
+			    strlcpy(latestdir, ldir, sizeof latestdir);
 			    bmake_free(tp);
 			}
 			ldir = Var_Value(lcwd_vname, VAR_GLOBAL, &tp);
 			if (ldir) {
-			    strlcpy(lcwd, ldir, sizeof(lcwd));
+			    strlcpy(lcwd, ldir, sizeof lcwd);
 			    bmake_free(tp);
 			}
 		    }
@@ -1266,9 +1266,9 @@ meta_oodate(GNode *gn, Boolean oodate)
 
 			child = atoi(p);
 			if (child > 0) {
-			    snprintf(cldir, sizeof(cldir), LCWD_VNAME_FMT, child);
+			    snprintf(cldir, sizeof cldir, LCWD_VNAME_FMT, child);
 			    Var_Set(cldir, lcwd, VAR_GLOBAL);
-			    snprintf(cldir, sizeof(cldir), LDIR_VNAME_FMT, child);
+			    snprintf(cldir, sizeof cldir, LDIR_VNAME_FMT, child);
 			    Var_Set(cldir, latestdir, VAR_GLOBAL);
 #ifdef DEBUG_META_MODE
 			    if (DEBUG(META))
@@ -1283,8 +1283,8 @@ meta_oodate(GNode *gn, Boolean oodate)
 
 		case 'C':		/* Chdir */
 		    /* Update lcwd and latest directory. */
-		    strlcpy(latestdir, p, sizeof(latestdir));
-		    strlcpy(lcwd, p, sizeof(lcwd));
+		    strlcpy(latestdir, p, sizeof latestdir);
+		    strlcpy(lcwd, p, sizeof lcwd);
 		    Var_Set(lcwd_vname, lcwd, VAR_GLOBAL);
 		    Var_Set(ldir_vname, lcwd, VAR_GLOBAL);
 #ifdef DEBUG_META_MODE
@@ -1420,17 +1420,17 @@ meta_oodate(GNode *gn, Boolean oodate)
 				continue;  /* no point */
 
 			    /* Check vs latestdir */
-			    snprintf(fname1, sizeof(fname1), "%s/%s", latestdir, p);
+			    snprintf(fname1, sizeof fname1, "%s/%s", latestdir, p);
 			    sdirs[sdx++] = fname1;
 
 			    if (strcmp(latestdir, lcwd) != 0) {
 				/* Check vs lcwd */
-				snprintf(fname2, sizeof(fname2), "%s/%s", lcwd, p);
+				snprintf(fname2, sizeof fname2, "%s/%s", lcwd, p);
 				sdirs[sdx++] = fname2;
 			    }
 			    if (strcmp(lcwd, cwd) != 0) {
 				/* Check vs cwd */
-				snprintf(fname3, sizeof(fname3), "%s/%s", cwd, p);
+				snprintf(fname3, sizeof fname3, "%s/%s", cwd, p);
 				sdirs[sdx++] = fname3;
 			    }
 			}
@@ -1471,7 +1471,7 @@ meta_oodate(GNode *gn, Boolean oodate)
 		    }
 		    if (buf[0] == 'E') {
 			/* previous latestdir is no longer relevant */
-			strlcpy(latestdir, lcwd, sizeof(latestdir));
+			strlcpy(latestdir, lcwd, sizeof latestdir);
 		    }
 		    break;
 		default:
@@ -1681,7 +1681,7 @@ meta_compat_parent(pid_t child)
 
 	if (outfd != -1 && FD_ISSET(outfd, &readfds)) do {
 	    /* XXX this is not line-buffered */
-	    ssize_t nread = read(outfd, buf, sizeof(buf) - 1);
+	    ssize_t nread = read(outfd, buf, sizeof buf - 1);
 	    if (nread == -1)
 		err(1, "read");
 	    if (nread == 0) {

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.426 src/usr.bin/make/parse.c:1.427
--- src/usr.bin/make/parse.c:1.426	Wed Nov  4 13:31:58 2020
+++ src/usr.bin/make/parse.c	Thu Nov  5 17:27:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.426 2020/11/04 13:31:58 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.427 2020/11/05 17:27:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.426 2020/11/04 13:31:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.427 2020/11/05 17:27:16 rillig Exp $");
 
 /* types and constants */
 
@@ -360,7 +360,7 @@ loadedfile_create(const char *path)
 {
 	struct loadedfile *lf;
 
-	lf = bmake_malloc(sizeof(*lf));
+	lf = bmake_malloc(sizeof *lf);
 	lf->path = path == NULL ? "(stdin)" : path;
 	lf->buf = NULL;
 	lf->len = 0;
@@ -2064,7 +2064,7 @@ ParseMaybeSubMake(const char *cmd)
 	const char *name;
 	size_t len;
     } vals[] = {
-#define MKV(A)	{	A, sizeof(A) - 1	}
+#define MKV(A)	{	A, sizeof (A) - 1	}
 	MKV("${MAKE}"),
 	MKV("${.MAKE}"),
 	MKV("$(MAKE)"),

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.230 src/usr.bin/make/suff.c:1.231
--- src/usr.bin/make/suff.c:1.230	Sat Oct 31 11:54:33 2020
+++ src/usr.bin/make/suff.c	Thu Nov  5 17:27:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.230 2020/10/31 11:54:33 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.231 2020/11/05 17:27:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.230 2020/10/31 11:54:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.231 2020/11/05 17:27:16 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -387,7 +387,7 @@ SuffInsert(SuffList *list, Suff *suff)
 static Suff *
 SuffNew(const char *name)
 {
-    Suff *s = bmake_malloc(sizeof(Suff));
+    Suff *s = bmake_malloc(sizeof *s);
 
     s->name = bmake_strdup(name);
     s->nameLen = strlen(s->name);

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.126 src/usr.bin/make/targ.c:1.127
--- src/usr.bin/make/targ.c:1.126	Fri Oct 30 07:19:30 2020
+++ src/usr.bin/make/targ.c	Thu Nov  5 17:27:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.126 2020/10/30 07:19:30 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.127 2020/11/05 17:27:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.126 2020/10/30 07:19:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.127 2020/11/05 17:27:16 rillig Exp $");
 
 static GNodeList *allTargets;	/* the list of all targets found so far */
 #ifdef CLEANUP
@@ -176,7 +176,7 @@ Targ_NewGN(const char *name)
 {
     GNode *gn;
 
-    gn = bmake_malloc(sizeof(GNode));
+    gn = bmake_malloc(sizeof *gn);
     gn->name = bmake_strdup(name);
     gn->uname = NULL;
     gn->path = NULL;

Index: src/usr.bin/make/util.c
diff -u src/usr.bin/make/util.c:1.64 src/usr.bin/make/util.c:1.65
--- src/usr.bin/make/util.c:1.64	Tue Oct  6 21:51:33 2020
+++ src/usr.bin/make/util.c	Thu Nov  5 17:27:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.64 2020/10/06 21:51:33 rillig Exp $	*/
+/*	$NetBSD: util.c,v 1.65 2020/11/05 17:27:16 rillig Exp $	*/
 
 /*
  * Missing stuff from OS's
@@ -15,7 +15,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: util.c,v 1.64 2020/10/06 21:51:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: util.c,v 1.65 2020/11/05 17:27:16 rillig Exp $");
 
 #if !defined(MAKE_NATIVE) && !defined(HAVE_STRERROR)
 extern int errno, sys_nerr;
@@ -26,7 +26,7 @@ strerror(int e)
 {
     static char buf[100];
     if (e < 0 || e >= sys_nerr) {
-	snprintf(buf, sizeof(buf), "Unknown error %d", e);
+	snprintf(buf, sizeof buf, "Unknown error %d", e);
 	return buf;
     }
     else

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.658 src/usr.bin/make/var.c:1.659
--- src/usr.bin/make/var.c:1.658	Thu Nov  5 15:04:51 2020
+++ src/usr.bin/make/var.c	Thu Nov  5 17:27:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.658 2020/11/05 15:04:51 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.659 2020/11/05 17:27:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.658 2020/11/05 15:04:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.659 2020/11/05 17:27:16 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -584,7 +584,7 @@ Var_ExportVars(void)
      * children see a correctly incremented value.
      */
     char tmp[BUFSIZ];
-    snprintf(tmp, sizeof(tmp), "%d", makelevel + 1);
+    snprintf(tmp, sizeof tmp, "%d", makelevel + 1);
     setenv(MAKE_LEVEL_ENV, tmp, 1);
 
     if (var_exportedVars == VAR_EXPORTED_NONE)
@@ -1488,7 +1488,7 @@ VarSelectWords(char sep, Boolean oneBigW
     if (oneBigWord) {
 	/* fake what Str_Words() would do if there were only one word */
 	words.len = 1;
-	words.words = bmake_malloc((words.len + 1) * sizeof(char *));
+	words.words = bmake_malloc((words.len + 1) * sizeof(words.words[0]));
 	words.freeIt = bmake_strdup(str);
 	words.words[0] = words.freeIt;
 	words.words[1] = NULL;
@@ -1724,9 +1724,9 @@ VarStrftime(const char *fmt, Boolean zul
 	time(&tim);
     if (!*fmt)
 	fmt = "%c";
-    strftime(buf, sizeof(buf), fmt, zulu ? gmtime(&tim) : localtime(&tim));
+    strftime(buf, sizeof buf, fmt, zulu ? gmtime(&tim) : localtime(&tim));
 
-    buf[sizeof(buf) - 1] = '\0';
+    buf[sizeof buf - 1] = '\0';
     return bmake_strdup(buf);
 }
 
@@ -2829,7 +2829,7 @@ ApplyModifier_Order(const char **pp, App
 
     if (mod[1] == st->endc || mod[1] == ':') {
 	/* :O sorts ascending */
-	qsort(words.words, words.len, sizeof(char *), str_cmp_asc);
+	qsort(words.words, words.len, sizeof words.words[0], str_cmp_asc);
 
     } else if ((mod[1] == 'r' || mod[1] == 'x') &&
 	       (mod[2] == st->endc || mod[2] == ':')) {
@@ -2837,7 +2837,7 @@ ApplyModifier_Order(const char **pp, App
 
 	if (mod[1] == 'r') {
 	    /* :Or sorts descending */
-	    qsort(words.words, words.len, sizeof(char *), str_cmp_desc);
+	    qsort(words.words, words.len, sizeof words.words[0], str_cmp_desc);
 
 	} else {
 	    /* :Ox shuffles

Index: src/usr.bin/make/filemon/filemon_dev.c
diff -u src/usr.bin/make/filemon/filemon_dev.c:1.3 src/usr.bin/make/filemon/filemon_dev.c:1.4
--- src/usr.bin/make/filemon/filemon_dev.c:1.3	Fri Jul 10 15:53:30 2020
+++ src/usr.bin/make/filemon/filemon_dev.c	Thu Nov  5 17:27:16 2020
@@ -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 @@ filemon_open(void)
 	int error;
 
 	/* Allocate and zero a struct filemon object.  */
-	F = calloc(1, sizeof(*F));
+	F = calloc(1, sizeof *F);
 	if (F == NULL)
 		return NULL;
 
Index: src/usr.bin/make/filemon/filemon_ktrace.c
diff -u src/usr.bin/make/filemon/filemon_ktrace.c:1.3 src/usr.bin/make/filemon/filemon_ktrace.c:1.4
--- src/usr.bin/make/filemon/filemon_ktrace.c:1.3	Sun Oct 18 11:54:43 2020
+++ src/usr.bin/make/filemon/filemon_ktrace.c	Thu Nov  5 17:27:16 2020
@@ -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 @@ filemon_open(void)
 	int error;
 
 	/* Allocate and zero a struct filemon object.  */
-	F = calloc(1, sizeof(*F));
+	F = calloc(1, sizeof *F);
 	if (F == NULL)
 		return NULL;
 

Reply via email to