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): make a few more bool expressions more ...



details:   https://anonhg.NetBSD.org/src/rev/3c1764202de0
branches:  trunk
changeset: 949369:3c1764202de0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 10 23:59:53 2021 +0000

description:
make(1): make a few more bool expressions more precise

The previous version of lint(1) from a few hours ago didn't catch all
occurrences.  And even the current one doesn't catch everything.
Function arguments and return types still need some work.  The "return
quietly" from shouldDieQuietly still implicitly converts from int to
_Bool.

No functional change.

diffstat:

 usr.bin/make/filemon/filemon_ktrace.c |   8 ++++----
 usr.bin/make/job.c                    |  12 ++++++------
 usr.bin/make/main.c                   |  12 ++++++------
 usr.bin/make/str.c                    |   8 ++++----
 usr.bin/make/targ.c                   |   6 +++---
 usr.bin/make/var.c                    |   8 ++++----
 6 files changed, 27 insertions(+), 27 deletions(-)

diffs (238 lines):

diff -r b737121146cf -r 3c1764202de0 usr.bin/make/filemon/filemon_ktrace.c
--- a/usr.bin/make/filemon/filemon_ktrace.c     Sun Jan 10 23:24:25 2021 +0000
+++ b/usr.bin/make/filemon/filemon_ktrace.c     Sun Jan 10 23:59:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filemon_ktrace.c,v 1.11 2021/01/10 21:20:47 rillig Exp $       */
+/*     $NetBSD: filemon_ktrace.c,v 1.12 2021/01/10 23:59:53 rillig Exp $       */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -519,10 +519,10 @@
                return 0;
 
        /* If we're waiting for input, read some.  */
-       if (F->resid) {
+       if (F->resid > 0) {
                nread = fread(F->p, 1, F->resid, F->in);
                if (nread == 0) {
-                       if (feof(F->in))
+                       if (feof(F->in) != 0)
                                return 0;
                        assert(ferror(F->in) != 0);
                        /*
@@ -539,7 +539,7 @@
                assert(nread <= F->resid);
                F->p += nread;
                F->resid -= nread;
-               if (F->resid)   /* may be more events */
+               if (F->resid > 0)       /* may be more events */
                        return 1;
        }
 
diff -r b737121146cf -r 3c1764202de0 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sun Jan 10 23:24:25 2021 +0000
+++ b/usr.bin/make/job.c        Sun Jan 10 23:59:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.396 2021/01/10 21:20:46 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.397 2021/01/10 23:59:53 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.396 2021/01/10 21:20:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.397 2021/01/10 23:59:53 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1539,7 +1539,7 @@
                    (!job->echo ? "" :
                        (shell->echoFlag != NULL ? shell->echoFlag : "")));
 
-               if (args[1]) {
+               if (args[1] != '\0') {
                        argv[argc] = args;
                        argc++;
                }
@@ -2286,7 +2286,7 @@
 static void
 DelSig(int sig)
 {
-       if (sigismember(&caught_signals, sig))
+       if (sigismember(&caught_signals, sig) != 0)
                (void)bmake_signal(sig, SIG_DFL);
 }
 
@@ -2557,7 +2557,7 @@
                gn = job->node;
 
                JobDeleteTarget(gn);
-               if (job->pid) {
+               if (job->pid != 0) {
                        DEBUG2(JOB,
                            "JobInterrupt passing signal %d to child %d.\n",
                            signo, job->pid);
@@ -2728,7 +2728,7 @@
                 * pollfd number should be even.
                 */
                assert(nfds_per_job() == 2);
-               if (i % 2)
+               if (i % 2 != 0)
                        Punt("odd-numbered fd with meta");
                nJobs--;
        }
diff -r b737121146cf -r 3c1764202de0 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Jan 10 23:24:25 2021 +0000
+++ b/usr.bin/make/main.c       Sun Jan 10 23:59:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.511 2021/01/10 21:20:46 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.512 2021/01/10 23:59:53 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -110,7 +110,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.511 2021/01/10 21:20:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.512 2021/01/10 23:59:53 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -159,7 +159,7 @@
        if (flags == NULL)
                return NULL;
 
-       for (f = flags; *f; f++)
+       for (f = flags; *f != '\0'; f++)
                if (!ch_isalpha(*f))
                        break;
 
@@ -243,7 +243,7 @@
        const char *modules;
        DebugFlags debug = opts.debug;
 
-       for (modules = argvalue; *modules; ++modules) {
+       for (modules = argvalue; *modules != '\0'; ++modules) {
                switch (*modules) {
                case '0':       /* undocumented, only intended for tests */
                        debug = DEBUG_NONE;
@@ -790,7 +790,7 @@
 
        const char *sep = " \t";
 
-       for (n = 0, cp = strtok(str, sep); cp; cp = strtok(NULL, sep)) {
+       for (n = 0, cp = strtok(str, sep); cp != NULL; cp = strtok(NULL, sep)) {
                Lst_Append(lp, cp);
                n++;
        }
@@ -2093,7 +2093,7 @@
                else if (bf >= 0)
                        quietly = bf;
                else
-                       quietly = gn != NULL && (gn->type & OP_MAKE);
+                       quietly = (gn != NULL && (gn->type & OP_MAKE)) ? 1 : 0;
        }
        return quietly;
 }
diff -r b737121146cf -r 3c1764202de0 usr.bin/make/str.c
--- a/usr.bin/make/str.c        Sun Jan 10 23:24:25 2021 +0000
+++ b/usr.bin/make/str.c        Sun Jan 10 23:59:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: str.c,v 1.77 2021/01/10 21:20:46 rillig Exp $  */
+/*     $NetBSD: str.c,v 1.78 2021/01/10 23:59:53 rillig Exp $  */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*     "@(#)str.c      5.8 (Berkeley) 6/1/90"  */
-MAKE_RCSID("$NetBSD: str.c,v 1.77 2021/01/10 21:20:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.78 2021/01/10 23:59:53 rillig Exp $");
 
 /* Return the concatenation of s1 and s2, freshly allocated. */
 char *
@@ -161,7 +161,7 @@
                switch (ch) {
                case '"':
                case '\'':
-                       if (inquote) {
+                       if (inquote != '\0') {
                                if (inquote == ch)
                                        inquote = '\0';
                                else
@@ -189,7 +189,7 @@
                case ' ':
                case '\t':
                case '\n':
-                       if (inquote)
+                       if (inquote != '\0')
                                break;
                        if (word_start == NULL)
                                continue;
diff -r b737121146cf -r 3c1764202de0 usr.bin/make/targ.c
--- a/usr.bin/make/targ.c       Sun Jan 10 23:24:25 2021 +0000
+++ b/usr.bin/make/targ.c       Sun Jan 10 23:59:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: targ.c,v 1.159 2020/12/18 15:47:34 rillig Exp $        */
+/*     $NetBSD: targ.c,v 1.160 2021/01/10 23:59:53 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -113,7 +113,7 @@
 #include "dir.h"
 
 /*     "@(#)targ.c     8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.159 2020/12/18 15:47:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.160 2021/01/10 23:59:53 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -514,7 +514,7 @@
                }
                PrintNodeNamesLine("implicit parents", &gn->implicitParents);
        } else {
-               if (gn->unmade)
+               if (gn->unmade != 0)
                        debug_printf("# %d unmade children\n", gn->unmade);
        }
 
diff -r b737121146cf -r 3c1764202de0 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Jan 10 23:24:25 2021 +0000
+++ b/usr.bin/make/var.c        Sun Jan 10 23:59:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.780 2021/01/10 21:20:47 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.781 2021/01/10 23:59:53 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.780 2021/01/10 21:20:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.781 2021/01/10 23:59:53 rillig Exp $");
 
 typedef enum VarFlags {
        VAR_NONE        = 0,
@@ -1536,7 +1536,7 @@
                args->matched = TRUE;
                SepBuf_AddBytes(buf, wp, (size_t)m[0].rm_so);
 
-               for (rp = args->replace; *rp; rp++) {
+               for (rp = args->replace; *rp != '\0'; rp++) {
                        if (*rp == '\\' && (rp[1] == '&' || rp[1] == '\\')) {
                                SepBuf_AddBytes(buf, rp + 1, 1);
                                rp++;
@@ -1840,7 +1840,7 @@
        size_t i;
 
        size_t len;
-       for (len = len2; len;) {
+       for (len = len2; len != 0;) {
                uint32_t k = 0;
                switch (len) {
                default:



Home | Main Index | Thread Index | Old Index