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 properly typed comparisons in bool...



details:   https://anonhg.NetBSD.org/src/rev/c2b2c7562336
branches:  trunk
changeset: 1016561:c2b2c7562336
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 23 20:52:59 2020 +0000

description:
make(1): use properly typed comparisons in boolean contexts

diffstat:

 usr.bin/make/cond.c  |   6 +++---
 usr.bin/make/dir.c   |  10 +++++-----
 usr.bin/make/main.c  |   8 ++++----
 usr.bin/make/meta.c  |   6 +++---
 usr.bin/make/parse.c |  14 +++++++-------
 usr.bin/make/var.c   |  11 +++++------
 6 files changed, 27 insertions(+), 28 deletions(-)

diffs (223 lines):

diff -r 2fb5da5613eb -r c2b2c7562336 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Mon Nov 23 20:41:20 2020 +0000
+++ b/usr.bin/make/cond.c       Mon Nov 23 20:52:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.216 2020/11/23 20:41:20 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.217 2020/11/23 20:52:59 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,7 +94,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.216 2020/11/23 20:41:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.217 2020/11/23 20:52:59 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -486,7 +486,7 @@
                                goto cleanup;
 
                        Buf_AddStr(&buf, str);
-                       if (*out_freeIt) {
+                       if (*out_freeIt != NULL) {
                                free(*out_freeIt);
                                *out_freeIt = NULL;
                        }
diff -r 2fb5da5613eb -r c2b2c7562336 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Mon Nov 23 20:41:20 2020 +0000
+++ b/usr.bin/make/dir.c        Mon Nov 23 20:52:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.213 2020/11/23 20:41:20 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.214 2020/11/23 20:52:59 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.213 2020/11/23 20:41:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.214 2020/11/23 20:52:59 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -770,16 +770,16 @@
     DIR_DEBUG1("Expanding \"%s\"... ", word);
 
     cp = strchr(word, '{');
-    if (cp) {
+    if (cp != NULL) {
        DirExpandCurly(word, cp, path, expansions);
     } else {
        cp = strchr(word, '/');
-       if (cp) {
+       if (cp != NULL) {
            /*
             * The thing has a directory component -- find the first wildcard
             * in the string.
             */
-           for (cp = word; *cp; cp++) {
+           for (cp = word; *cp != '\0'; cp++) {
                if (*cp == '?' || *cp == '[' || *cp == '*') {
                    break;
                }
diff -r 2fb5da5613eb -r c2b2c7562336 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Mon Nov 23 20:41:20 2020 +0000
+++ b/usr.bin/make/main.c       Mon Nov 23 20:52:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.476 2020/11/16 22:08:20 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.477 2020/11/23 20:52:59 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.476 2020/11/16 22:08:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.477 2020/11/23 20:52:59 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -167,12 +167,12 @@
                if (!ch_isalpha(*f))
                        break;
 
-       if (*f)
+       if (*f != '\0')
                return bmake_strdup(flags);
 
        len = strlen(flags);
        st = nf = bmake_malloc(len * 3 + 1);
-       while (*flags) {
+       while (*flags != '\0') {
                *nf++ = '-';
                *nf++ = *flags++;
                *nf++ = ' ';
diff -r 2fb5da5613eb -r c2b2c7562336 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Mon Nov 23 20:41:20 2020 +0000
+++ b/usr.bin/make/meta.c       Mon Nov 23 20:52:59 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.145 2020/11/23 20:41:20 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.146 2020/11/23 20:52:59 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -491,7 +491,7 @@
        /* Describe the target we are building */
        (void)Var_Subst("${" MAKE_META_PREFIX "}", gn, VARE_WANTRES, &mp);
        /* TODO: handle errors */
-       if (*mp)
+       if (mp[0] != '\0')
            fprintf(stdout, "%s\n", mp);
        free(mp);
     }
@@ -995,7 +995,7 @@
        expr = "${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}";
        (void)Var_Subst(expr, gn, VARE_WANTRES, &pm);
        /* TODO: handle errors */
-       if (*pm) {
+       if (pm[0] != '\0') {
 #ifdef DEBUG_META_MODE
            DEBUG1(META, "meta_oodate: ignoring pattern: %s\n", p);
 #endif
diff -r 2fb5da5613eb -r c2b2c7562336 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Mon Nov 23 20:41:20 2020 +0000
+++ b/usr.bin/make/parse.c      Mon Nov 23 20:52:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.449 2020/11/23 20:41:20 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.450 2020/11/23 20:52:59 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.449 2020/11/23 20:41:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.450 2020/11/23 20:52:59 rillig Exp $");
 
 /* types and constants */
 
@@ -1516,8 +1516,8 @@
 {
     char savec;
 
-    while (*start) {
-       while (*end && !ch_isspace(*end))
+    while (*start != '\0') {
+       while (*end != '\0' && !ch_isspace(*end))
            end++;
        savec = *end;
        *end = '\0';
@@ -1540,7 +1540,7 @@
         * specifications (i.e. things with left parentheses in them)
         * and handle them accordingly.
         */
-       for (; *end && !ch_isspace(*end); end++) {
+       for (; *end != '\0' && !ch_isspace(*end); end++) {
            if (*end == '(' && end > start && end[-1] != '$') {
                /*
                 * Only stop for a left parenthesis if it isn't at the
@@ -1567,7 +1567,7 @@
            Lst_Free(sources);
            end = start;
        } else {
-           if (*end) {
+           if (*end != '\0') {
                *end = '\0';
                end++;
            }
@@ -2480,7 +2480,7 @@
 
     for (file = all_files; !done; file = cp + 1) {
        /* Skip to end of line or next whitespace */
-       for (cp = file; *cp && !ch_isspace(*cp); cp++)
+       for (cp = file; *cp != '\0' && !ch_isspace(*cp); cp++)
            continue;
 
        if (*cp != '\0')
diff -r 2fb5da5613eb -r c2b2c7562336 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Nov 23 20:41:20 2020 +0000
+++ b/usr.bin/make/var.c        Mon Nov 23 20:52:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.693 2020/11/21 18:41:57 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.694 2020/11/23 20:52:59 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.693 2020/11/21 18:41:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.694 2020/11/23 20:52:59 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -605,7 +605,7 @@
 
     (void)Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL, VARE_WANTRES, &val);
     /* TODO: handle errors */
-    if (*val) {
+    if (val[0] != '\0') {
        Words words = Str_Words(val, FALSE);
        size_t i;
 
@@ -1420,12 +1420,11 @@
                SepBuf_AddBytes(buf, wp, 1);
                wp++;
            }
-           if (*wp)
+           if (*wp != '\0')
                goto tryagain;
        }
-       if (*wp) {
+       if (*wp != '\0')
            SepBuf_AddStr(buf, wp);
-       }
        break;
     default:
        VarREError(xrv, &args->re, "Unexpected regex error");



Home | Main Index | Thread Index | Old Index