Module Name: src Committed By: rillig Date: Wed Dec 15 10:04:49 UTC 2021
Modified Files: src/usr.bin/make: compat.c job.c nonints.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/compat.c cvs rdiff -u -r1.440 -r1.441 src/usr.bin/make/job.c cvs rdiff -u -r1.219 -r1.220 src/usr.bin/make/nonints.h 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/compat.c diff -u src/usr.bin/make/compat.c:1.229 src/usr.bin/make/compat.c:1.230 --- src/usr.bin/make/compat.c:1.229 Sun Nov 28 23:12:51 2021 +++ src/usr.bin/make/compat.c Wed Dec 15 10:04:49 2021 @@ -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 @@ UseShell(const char *cmd MAKE_ATTR_UNUSE * 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 @@ Compat_RunCommand(const char *cmdp, GNod if (cmdStart[0] == '\0') { free(cmdStart); - return 0; + return true; } cmd = cmdStart; LstNode_Set(ln, cmdStart); @@ -266,12 +266,12 @@ Compat_RunCommand(const char *cmdp, GNod * 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 @@ Compat_RunCommand(const char *cmdp, GNod * 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 @@ Compat_RunCommand(const char *cmdp, GNod * we go... */ if (!doIt && !GNode_ShouldExecute(gn)) - return 0; + return true; DEBUG1(JOB, "Execute: '%s'\n", cmd); @@ -454,7 +454,7 @@ Compat_RunCommand(const char *cmdp, GNod kill(myPid, compatSigno); } - return status; + return status == 0; } static void @@ -464,7 +464,7 @@ RunCommands(GNode *gn) 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; } } Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.440 src/usr.bin/make/job.c:1.441 --- src/usr.bin/make/job.c:1.440 Sun Nov 28 19:51:06 2021 +++ src/usr.bin/make/job.c Wed Dec 15 10:04:49 2021 @@ -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 @@ JobWriteCommand(Job *job, ShellWriter *w 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 @@ JobWriteCommand(Job *job, ShellWriter *w * 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; } Index: src/usr.bin/make/nonints.h diff -u src/usr.bin/make/nonints.h:1.219 src/usr.bin/make/nonints.h:1.220 --- src/usr.bin/make/nonints.h:1.219 Wed Dec 15 09:53:41 2021 +++ src/usr.bin/make/nonints.h Wed Dec 15 10:04:49 2021 @@ -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_LibOODate(GNode *) MAKE_ATTR_U 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 *);