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): use strict typing in conditions of the...



details:   https://anonhg.NetBSD.org/src/rev/9da5985ae88c
branches:  trunk
changeset: 978077:9da5985ae88c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 08 15:07:37 2020 +0000

description:
make(1): use strict typing in conditions of the form !var

diffstat:

 usr.bin/make/job.c   |  14 +++++++-------
 usr.bin/make/main.c  |  18 +++++++++---------
 usr.bin/make/meta.c  |  20 ++++++++++----------
 usr.bin/make/parse.c |  10 +++++-----
 usr.bin/make/var.c   |   8 ++++----
 5 files changed, 35 insertions(+), 35 deletions(-)

diffs (293 lines):

diff -r 128930df1f28 -r 9da5985ae88c usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sun Nov 08 14:55:25 2020 +0000
+++ b/usr.bin/make/job.c        Sun Nov 08 15:07:37 2020 +0000
@@ -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 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 @@
     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 @@
        if (rval > 0)
            continue;
        if (rval == 0)
-           lurking_children = 1;
+           lurking_children = TRUE;
        break;
     }
 
@@ -2579,7 +2579,7 @@
            /* Job exit deferred after calling waitpid() in a signal handler */
            JobFinish(job, job->exit_status);
     }
-    make_suspended = 0;
+    make_suspended = FALSE;
 }
 
 static void
diff -r 128930df1f28 -r 9da5985ae88c usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Nov 08 14:55:25 2020 +0000
+++ b/usr.bin/make/main.c       Sun Nov 08 15:07:37 2020 +0000
@@ -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 @@
        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 @@
        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 @@
                }
                /* 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 @@
 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 @@
 {
        static char *tmpdir = NULL;
 
-       if (!tmpdir) {
+       if (tmpdir == NULL) {
                struct stat st;
 
                /*
diff -r 128930df1f28 -r 9da5985ae88c usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sun Nov 08 14:55:25 2020 +0000
+++ b/usr.bin/make/meta.c       Sun Nov 08 15:07:37 2020 +0000
@@ -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 @@
     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 @@
 
     if (job != NULL) {
        pbm = &job->bm;
-       if (!gn)
+       if (gn == NULL)
            gn = job->node;
     } else {
        pbm = &Mybm;
@@ -816,7 +816,7 @@
            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 @@
                *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 @@
     FILE *fp;
     Boolean needOODATE = FALSE;
     StringList *missingFiles;
-    int have_filemon = FALSE;
+    Boolean have_filemon = FALSE;
     void *objdir_freeIt;
 
     if (oodate)
@@ -1127,12 +1127,12 @@
        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 @@
        strlcpy(lcwd, cwd, sizeof lcwd);
        strlcpy(latestdir, cwd, sizeof latestdir);
 
-       if (!tmpdir) {
+       if (tmpdir == NULL) {
            tmpdir = getTmpdir();
            tmplen = strlen(tmpdir);
        }
@@ -1585,7 +1585,7 @@
                    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 */
diff -r 128930df1f28 -r 9da5985ae88c usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sun Nov 08 14:55:25 2020 +0000
+++ b/usr.bin/make/parse.c      Sun Nov 08 15:07:37 2020 +0000
@@ -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 @@
  * 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 @@
 {
     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 @@
 {
     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;
 
diff -r 128930df1f28 -r 9da5985ae88c usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Nov 08 14:55:25 2020 +0000
+++ b/usr.bin/make/var.c        Sun Nov 08 15:07:37 2020 +0000
@@ -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 @@
 {
     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));
 



Home | Main Index | Thread Index | Old Index