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: change return type of Compat_RunCommand f...



details:   https://anonhg.NetBSD.org/src/rev/a9f9d62cebf5
branches:  trunk
changeset: 1027676:a9f9d62cebf5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 15 10:04:49 2021 +0000

description:
make: change return type of Compat_RunCommand from int to bool

The documentation was wrong before since status was not restricted to
only 0 or 1.

No functional change.

diffstat:

 usr.bin/make/compat.c  |  22 +++++++++++-----------
 usr.bin/make/job.c     |   8 ++++----
 usr.bin/make/nonints.h |   4 ++--
 3 files changed, 17 insertions(+), 17 deletions(-)

diffs (144 lines):

diff -r 713721edbb56 -r a9f9d62cebf5 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Wed Dec 15 09:54:56 2021 +0000
+++ b/usr.bin/make/compat.c     Wed Dec 15 10:04:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.229 2021/11/28 23:12:51 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.230 2021/12/15 10:04:49 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.229 2021/11/28 23:12:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.230 2021/12/15 10:04:49 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -217,9 +217,9 @@
  *     ln              List node that contains the command
  *
  * Results:
- *     0 if the command succeeded, 1 if an error occurred.
+ *     true if the command succeeded.
  */
-int
+bool
 Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln)
 {
        char *cmdStart;         /* Start of expanded command */
@@ -246,7 +246,7 @@
 
        if (cmdStart[0] == '\0') {
                free(cmdStart);
-               return 0;
+               return true;
        }
        cmd = cmdStart;
        LstNode_Set(ln, cmdStart);
@@ -266,12 +266,12 @@
                         * usual '$$'.
                         */
                        Lst_Append(&endNode->commands, cmdStart);
-                       return 0;
+                       return true;
                }
        }
        if (strcmp(cmdStart, "...") == 0) {
                gn->type |= OP_SAVE_CMDS;
-               return 0;
+               return true;
        }
 
        for (;;) {
@@ -295,7 +295,7 @@
         * If we did not end up with a command, just skip it.
         */
        if (cmd[0] == '\0')
-               return 0;
+               return true;
 
        useShell = UseShell(cmd);
        /*
@@ -312,7 +312,7 @@
         * we go...
         */
        if (!doIt && !GNode_ShouldExecute(gn))
-               return 0;
+               return true;
 
        DEBUG1(JOB, "Execute: '%s'\n", cmd);
 
@@ -454,7 +454,7 @@
                kill(myPid, compatSigno);
        }
 
-       return status;
+       return status == 0;
 }
 
 static void
@@ -464,7 +464,7 @@
 
        for (ln = gn->commands.first; ln != NULL; ln = ln->next) {
                const char *cmd = ln->datum;
-               if (Compat_RunCommand(cmd, gn, ln) != 0)
+               if (!Compat_RunCommand(cmd, gn, ln))
                        break;
        }
 }
diff -r 713721edbb56 -r a9f9d62cebf5 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Wed Dec 15 09:54:56 2021 +0000
+++ b/usr.bin/make/job.c        Wed Dec 15 10:04:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.440 2021/11/28 19:51:06 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.441 2021/12/15 10:04:49 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.440 2021/11/28 19:51:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.441 2021/12/15 10:04:49 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -911,7 +911,7 @@
 
        run = GNode_ShouldExecute(job->node);
 
-       Var_Subst(ucmd, job->node, VARE_WANTRES, &xcmd);
+       (void)Var_Subst(ucmd, job->node, VARE_WANTRES, &xcmd);
        /* TODO: handle errors */
        xcmdStart = xcmd;
 
@@ -925,7 +925,7 @@
                 * We're not actually executing anything...
                 * but this one needs to be - use compat mode just for it.
                 */
-               Compat_RunCommand(ucmd, job->node, ln);
+               (void)Compat_RunCommand(ucmd, job->node, ln);
                free(xcmdStart);
                return;
        }
diff -r 713721edbb56 -r a9f9d62cebf5 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Wed Dec 15 09:54:56 2021 +0000
+++ b/usr.bin/make/nonints.h    Wed Dec 15 10:04:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.219 2021/12/15 09:53:41 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.220 2021/12/15 10:04:49 rillig Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -86,7 +86,7 @@
 bool Arch_IsLib(GNode *) MAKE_ATTR_USE;
 
 /* compat.c */
-int Compat_RunCommand(const char *, GNode *, StringListNode *);
+bool Compat_RunCommand(const char *, GNode *, StringListNode *);
 void Compat_Run(GNodeList *);
 void Compat_Make(GNode *, GNode *);
 



Home | Main Index | Thread Index | Old Index