Module Name: src Committed By: rillig Date: Sun Nov 8 15:07:37 UTC 2020
Modified Files: src/usr.bin/make: job.c main.c meta.c parse.c var.c Log Message: make(1): use strict typing in conditions of the form !var To generate a diff of this commit: cvs rdiff -u -r1.315 -r1.316 src/usr.bin/make/job.c cvs rdiff -u -r1.453 -r1.454 src/usr.bin/make/main.c cvs rdiff -u -r1.140 -r1.141 src/usr.bin/make/meta.c cvs rdiff -u -r1.433 -r1.434 src/usr.bin/make/parse.c cvs rdiff -u -r1.675 -r1.676 src/usr.bin/make/var.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/job.c diff -u src/usr.bin/make/job.c:1.315 src/usr.bin/make/job.c:1.316 --- src/usr.bin/make/job.c:1.315 Sun Nov 8 09:34:55 2020 +++ src/usr.bin/make/job.c Sun Nov 8 15:07:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.315 2020/11/08 09:34:55 rillig Exp $ */ +/* $NetBSD: job.c,v 1.316 2020/11/08 15:07:37 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.315 2020/11/08 09:34:55 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.316 2020/11/08 15:07:37 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 @@ -375,8 +375,8 @@ static char *shellArgv = NULL; /* Custom static Job *job_table; /* The structures that describe them */ static Job *job_table_end; /* job_table + maxJobs */ static unsigned int wantToken; /* we want a token */ -static int lurking_children = 0; -static int make_suspended = 0; /* non-zero if we've seen a SIGTSTP (etc) */ +static Boolean lurking_children = FALSE; +static Boolean make_suspended = FALSE; /* Whether we've seen a SIGTSTP (etc) */ /* * Set of descriptors of pipes connected to @@ -583,7 +583,7 @@ JobPassSig_suspend(int signo) struct sigaction act; /* Suppress job started/continued messages */ - make_suspended = 1; + make_suspended = TRUE; /* Pass the signal onto every job */ JobCondPassSig(signo); @@ -2139,7 +2139,7 @@ Job_Init(void) if (rval > 0) continue; if (rval == 0) - lurking_children = 1; + lurking_children = TRUE; break; } @@ -2579,7 +2579,7 @@ JobRestartJobs(void) /* Job exit deferred after calling waitpid() in a signal handler */ JobFinish(job, job->exit_status); } - make_suspended = 0; + make_suspended = FALSE; } static void Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.453 src/usr.bin/make/main.c:1.454 --- src/usr.bin/make/main.c:1.453 Sun Nov 8 14:50:24 2020 +++ src/usr.bin/make/main.c Sun Nov 8 15:07:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.453 2020/11/08 14:50:24 rillig Exp $ */ +/* $NetBSD: main.c,v 1.454 2020/11/08 15:07:37 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.453 2020/11/08 14:50:24 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.454 2020/11/08 15:07:37 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -785,7 +785,7 @@ str2Lst_Append(StringList *lp, char *str char *cp; int n; - if (!sep) + if (sep == NULL) sep = " \t"; for (n = 0, cp = strtok(str, sep); cp; cp = strtok(NULL, sep)) { @@ -1678,12 +1678,12 @@ ReadMakefile(const char *fname) int fd; char *name, *path = NULL; - if (!strcmp(fname, "-")) { + if (strcmp(fname, "-") == 0) { Parse_File(NULL /*stdin*/, -1); Var_Set("MAKEFILE", "", VAR_INTERNAL); } else { /* if we've chdir'd, rebuild the path name */ - if (strcmp(curdir, objdir) && *fname != '/') { + if (strcmp(curdir, objdir) != 0 && *fname != '/') { path = str_concat3(curdir, "/", fname); fd = open(path, O_RDONLY); if (fd != -1) { @@ -1706,12 +1706,12 @@ ReadMakefile(const char *fname) } /* look in -I and system include directories. */ name = Dir_FindFile(fname, parseIncPath); - if (!name) { + if (name == NULL) { SearchPath *sysInc = Lst_IsEmpty(sysIncPath) ? defSysIncPath : sysIncPath; name = Dir_FindFile(fname, sysInc); } - if (!name || (fd = open(name, O_RDONLY)) == -1) { + if (name == NULL || (fd = open(name, O_RDONLY)) == -1) { free(name); free(path); return -1; @@ -2017,7 +2017,7 @@ static GNode * get_cached_realpaths(void) { - if (!cached_realpaths) { + if (cached_realpaths == NULL) { cached_realpaths = Targ_NewGN("Realpath"); #ifndef DEBUG_REALPATH_CACHE cached_realpaths->flags = INTERNAL; @@ -2183,7 +2183,7 @@ getTmpdir(void) { static char *tmpdir = NULL; - if (!tmpdir) { + if (tmpdir == NULL) { struct stat st; /* Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.140 src/usr.bin/make/meta.c:1.141 --- src/usr.bin/make/meta.c:1.140 Sat Nov 7 21:26:43 2020 +++ src/usr.bin/make/meta.c Sun Nov 8 15:07:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.140 2020/11/07 21:26:43 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.141 2020/11/08 15:07:37 rillig Exp $ */ /* * Implement 'meta' mode. @@ -324,7 +324,7 @@ is_submake(void *cmdp, void *gnp) char *cp2; int rc = 0; /* keep looking */ - if (!p_make) { + if (p_make == NULL) { void *dontFreeIt; p_make = Var_Value(".MAKE", gn, &dontFreeIt); p_len = strlen(p_make); @@ -779,7 +779,7 @@ meta_job_error(Job *job, GNode *gn, int if (job != NULL) { pbm = &job->bm; - if (!gn) + if (gn == NULL) gn = job->node; } else { pbm = &Mybm; @@ -816,7 +816,7 @@ meta_job_output(Job *job, char *cp, cons static char *meta_prefix = NULL; static size_t meta_prefix_len; - if (!meta_prefix) { + if (meta_prefix == NULL) { char *cp2; (void)Var_Subst("${" MAKE_META_PREFIX "}", @@ -938,7 +938,7 @@ fgetLine(char **bufp, size_t *szp, int o *bufp = buf = p; *szp = bufsz = newsz; /* fetch the rest */ - if (!fgets(&buf[x], (int)bufsz - x, fp)) + if (fgets(&buf[x], (int)bufsz - x, fp) == NULL) return x; /* truncated! */ goto check_newline; } @@ -1087,7 +1087,7 @@ meta_oodate(GNode *gn, Boolean oodate) FILE *fp; Boolean needOODATE = FALSE; StringList *missingFiles; - int have_filemon = FALSE; + Boolean have_filemon = FALSE; void *objdir_freeIt; if (oodate) @@ -1127,12 +1127,12 @@ meta_oodate(GNode *gn, Boolean oodate) StringListNode *cmdNode; struct make_stat mst; - if (!buf) { + if (buf == NULL) { bufsz = 8 * BUFSIZ; buf = bmake_malloc(bufsz); } - if (!cwdlen) { + if (cwdlen == 0) { if (getcwd(cwd, sizeof cwd) == NULL) err(1, "Could not get current working directory"); cwdlen = strlen(cwd); @@ -1140,7 +1140,7 @@ meta_oodate(GNode *gn, Boolean oodate) strlcpy(lcwd, cwd, sizeof lcwd); strlcpy(latestdir, cwd, sizeof latestdir); - if (!tmpdir) { + if (tmpdir == NULL) { tmpdir = getTmpdir(); tmplen = strlen(tmpdir); } @@ -1585,7 +1585,7 @@ meta_oodate(GNode *gn, Boolean oodate) cp = NULL; /* not in .CURDIR */ } } - if (!cp) { + if (cp == NULL) { DEBUG1(META, "%s: required but missing\n", fname); oodate = TRUE; needOODATE = TRUE; /* assume the worst */ Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.433 src/usr.bin/make/parse.c:1.434 --- src/usr.bin/make/parse.c:1.433 Sun Nov 8 02:37:22 2020 +++ src/usr.bin/make/parse.c Sun Nov 8 15:07:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.433 2020/11/08 02:37:22 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.434 2020/11/08 15:07:37 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.433 2020/11/08 02:37:22 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.434 2020/11/08 15:07:37 rillig Exp $"); /* types and constants */ @@ -2122,7 +2122,7 @@ Parse_AddIncludeDir(const char *dir) * the -I command line options. */ static void -Parse_include_file(char *file, Boolean isSystem, Boolean depinc, int silent) +Parse_include_file(char *file, Boolean isSystem, Boolean depinc, Boolean silent) { struct loadedfile *lf; char *fullname; /* full pathname of file */ @@ -2228,7 +2228,7 @@ ParseDoInclude(char *line) { char endc; /* the character which ends the file spec */ char *cp; /* current position in file spec */ - int silent = *line != 'i'; + Boolean silent = *line != 'i'; char *file = line + (silent ? 8 : 7); /* Skip to delimiter character so we know where to look */ @@ -2488,7 +2488,7 @@ ParseTraditionalInclude(char *line) { char *cp; /* current position in file spec */ Boolean done = FALSE; - int silent = line[0] != 'i'; + Boolean silent = line[0] != 'i'; char *file = line + (silent ? 8 : 7); char *all_files; Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.675 src/usr.bin/make/var.c:1.676 --- src/usr.bin/make/var.c:1.675 Sat Nov 7 22:28:24 2020 +++ src/usr.bin/make/var.c Sun Nov 8 15:07:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.675 2020/11/07 22:28:24 rillig Exp $ */ +/* $NetBSD: var.c,v 1.676 2020/11/08 15:07:37 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.675 2020/11/07 22:28:24 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.676 2020/11/08 15:07:37 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -1721,9 +1721,9 @@ VarStrftime(const char *fmt, Boolean zul { char buf[BUFSIZ]; - if (!tim) + if (tim == 0) time(&tim); - if (!*fmt) + if (*fmt == '\0') fmt = "%c"; strftime(buf, sizeof buf, fmt, zulu ? gmtime(&tim) : localtime(&tim));