From 8b03784eeb4fe7650453f14933b9a2d5d6c0bff2 Mon Sep 17 00:00:00 2001 From: rillig Date: Sat, 28 Nov 2020 08:40:05 +0000 Subject: [PATCH] make(1): rename conflicting global variables called 'error' When compiling make in all-in-one mode, these variable names conflict. They could have been merged into a single variable, but that would have required to make it a global variable for the other modules as well. The parse module has a similar variable called 'fatals'. All these can possibly be merged into a single variable, but not now. --- usr.bin/make/job.c | 20 ++++++++++---------- usr.bin/make/main.c | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index a70c6b925d19..07547eca0f81 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.330 2020/11/28 08:31:41 rillig Exp $ */ +/* $NetBSD: job.c,v 1.331 2020/11/28 08:40:05 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.330 2020/11/28 08:31:41 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.331 2020/11/28 08:40:05 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 @@ -215,7 +215,7 @@ typedef struct Shell { /* * error handling variables */ -static int errors = 0; /* number of errors reported */ +static int job_errors = 0; /* number of errors reported */ typedef enum AbortReason { /* why is the make aborting? */ ABORT_NONE, ABORT_ERROR, /* Because of an error */ @@ -952,7 +952,7 @@ JobClosePipes(Job *job) * * Deferred commands for the job are placed on the .END node. * - * If there was a serious error (errors != 0; not an ignored one), no more + * If there was a serious error (job_errors != 0; not an ignored one), no more * jobs will be started. * * Input: @@ -1080,18 +1080,18 @@ JobFinish(Job *job, int status) Make_Update(job->node); job->status = JOB_ST_FREE; } else if (status != 0) { - errors++; + job_errors++; job->status = JOB_ST_FREE; } - if (errors > 0 && !opts.keepgoing && aborting != ABORT_INTERRUPT) + if (job_errors > 0 && !opts.keepgoing && aborting != ABORT_INTERRUPT) aborting = ABORT_ERROR; /* Prevent more jobs from getting started. */ if (return_job_token) Job_TokenReturn(); if (aborting == ABORT_ERROR && jobTokensRunning == 0) - Finish(errors); + Finish(job_errors); } static void @@ -2082,7 +2082,7 @@ Job_Init(void) wantToken = 0; aborting = ABORT_NONE; - errors = 0; + job_errors = 0; lastNode = NULL; @@ -2452,13 +2452,13 @@ Job_Finish(void) { GNode *endNode = Targ_GetEndNode(); if (!Lst_IsEmpty(endNode->commands) || !Lst_IsEmpty(endNode->children)) { - if (errors != 0) { + if (job_errors != 0) { Error("Errors reported so .END ignored"); } else { JobRun(endNode); } } - return errors; + return job_errors; } /* Clean up any memory used by the jobs module. */ diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index d6c6f1a53038..1adabc72c288 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.480 2020/11/25 00:50:44 sjg Exp $ */ +/* $NetBSD: main.c,v 1.481 2020/11/28 08:40:05 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.480 2020/11/25 00:50:44 sjg Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.481 2020/11/28 08:40:05 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -146,7 +146,7 @@ pid_t myPid; int makelevel; Boolean forceJobs = FALSE; -static int errors = 0; +static int main_errors = 0; static HashTable cached_realpaths; /* @@ -1654,7 +1654,7 @@ main_CleanUp(void) static int main_Exit(Boolean outOfDate) { - if (opts.lint && (errors > 0 || Parse_GetFatals() > 0)) + if (opts.lint && (main_errors > 0 || Parse_GetFatals() > 0)) return 2; /* Not 1 so -q can distinguish error */ return outOfDate ? 1 : 0; } @@ -1880,7 +1880,7 @@ Error(const char *fmt, ...) break; err_file = stderr; } - errors++; + main_errors++; } /* Wait for any running jobs to finish, then produce an error message,