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): prepare job.c, main.c, parse.c, suff.c...
details: https://anonhg.NetBSD.org/src/rev/b0c80b83b37a
branches: trunk
changeset: 940208:b0c80b83b37a
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Oct 05 21:37:07 2020 +0000
description:
make(1): prepare job.c, main.c, parse.c, suff.c for WARNS=6
In job.c, GCC 5 complains about the macro FILENO that it has type
unsigned int, which is then passed as the argument of dup2, which
expects a simple int. Maybe this workaround from 1995 is not necessary
anymore, or maybe it is but can be restricted to the few affected
platforms.
This leaves meta.c and the filemon files to be converted. I didn't do
them since they are not well covered by the unit tests.
diffstat:
usr.bin/make/job.c | 46 +++++++++++++++++++++++-----------------------
usr.bin/make/job.h | 6 +++---
usr.bin/make/main.c | 10 +++++-----
usr.bin/make/parse.c | 18 +++++++++---------
usr.bin/make/suff.c | 8 ++++----
5 files changed, 44 insertions(+), 44 deletions(-)
diffs (truncated from 344 to 300 lines):
diff -r be08af460222 -r b0c80b83b37a usr.bin/make/job.c
--- a/usr.bin/make/job.c Mon Oct 05 21:11:47 2020 +0000
+++ b/usr.bin/make/job.c Mon Oct 05 21:37:07 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.260 2020/10/05 19:27:47 rillig Exp $ */
+/* $NetBSD: job.c,v 1.261 2020/10/05 21:37:07 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.260 2020/10/05 19:27:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.261 2020/10/05 21:37:07 rillig Exp $");
# define STATIC static
@@ -290,7 +290,7 @@
STATIC Job *job_table; /* The structures that describe them */
STATIC Job *job_table_end; /* job_table + maxJobs */
-static int wantToken; /* we want a token */
+static unsigned int wantToken; /* we want a token */
static int lurking_children = 0;
static int make_suspended = 0; /* non-zero if we've seen a SIGTSTP (etc) */
@@ -300,7 +300,7 @@
*/
static struct pollfd *fds = NULL;
static Job **jobfds = NULL;
-static int nfds = 0;
+static nfds_t nfds = 0;
static void watchfd(Job *);
static void clearfd(Job *);
static int readyfd(Job *);
@@ -314,7 +314,7 @@
#define CHILD_EXIT "."
#define DO_JOB_RESUME "R"
-static const int npseudojobs = 2; /* number of pseudo-jobs */
+enum { npseudojobs = 2 }; /* number of pseudo-jobs */
#define TARG_FMT "%s %s ---\n" /* Default format */
#define MESSAGE(fp, gn) \
@@ -1648,10 +1648,10 @@
{
Boolean gotNL = FALSE; /* true if got a newline */
Boolean fbuf; /* true if our buffer filled up */
- int nr; /* number of bytes read */
- int i; /* auxiliary index into outBuf */
- int max; /* limit for i (end of current data) */
- int nRead; /* (Temporary) number of bytes read */
+ size_t nr; /* number of bytes read */
+ size_t i; /* auxiliary index into outBuf */
+ size_t max; /* limit for i (end of current data) */
+ ssize_t nRead; /* (Temporary) number of bytes read */
/*
* Read as many bytes as will fit in the buffer.
@@ -1670,7 +1670,7 @@
}
nr = 0;
} else {
- nr = nRead;
+ nr = (size_t)nRead;
}
/*
@@ -1693,7 +1693,7 @@
* TRUE.
*/
max = job->curPos + nr;
- for (i = job->curPos + nr - 1; i >= job->curPos; i--) {
+ for (i = job->curPos + nr - 1; i >= job->curPos && i != (size_t)-1; i--) {
if (job->outBuf[i] == '\n') {
gotNL = TRUE;
break;
@@ -1892,7 +1892,7 @@
{
int nready;
Job *job;
- int i;
+ unsigned int i;
(void)fflush(stdout);
@@ -1926,9 +1926,9 @@
Job_CatchChildren();
if (nready == 0)
- return;
+ return;
- for (i = npseudojobs*nfds_per_job(); i < nfds; i++) {
+ for (i = npseudojobs * nfds_per_job(); i < nfds; i++) {
if (!fds[i].revents)
continue;
job = jobfds[i];
@@ -1947,7 +1947,7 @@
}
#endif
if (--nready == 0)
- return;
+ return;
}
}
@@ -1991,7 +1991,7 @@
shellErrFlag = NULL;
}
if (!shellErrFlag) {
- int n = strlen(commandShell->exit) + 2;
+ size_t n = strlen(commandShell->exit) + 2;
shellErrFlag = bmake_malloc(n);
if (shellErrFlag) {
@@ -2032,8 +2032,8 @@
{
Job_SetPrefix();
/* Allocate space for all the job info */
- job_table = bmake_malloc(maxJobs * sizeof *job_table);
- memset(job_table, 0, maxJobs * sizeof *job_table);
+ job_table = bmake_malloc((size_t)maxJobs * sizeof *job_table);
+ memset(job_table, 0, (size_t)maxJobs * sizeof *job_table);
job_table_end = job_table + maxJobs;
wantToken = 0;
@@ -2065,9 +2065,9 @@
/* Preallocate enough for the maximum number of jobs. */
fds = bmake_malloc(sizeof(*fds) *
- (npseudojobs + maxJobs) * nfds_per_job());
+ (npseudojobs + (size_t)maxJobs) * nfds_per_job());
jobfds = bmake_malloc(sizeof(*jobfds) *
- (npseudojobs + maxJobs) * nfds_per_job());
+ (npseudojobs + (size_t)maxJobs) * nfds_per_job());
/* These are permanent entries and take slots 0 and 1 */
watchfd(&tokenWaitJob);
@@ -2521,10 +2521,10 @@
static void
clearfd(Job *job)
{
- int i;
+ size_t i;
if (job->inPollfd == NULL)
Punt("Unwatching unwatched job");
- i = job->inPollfd - fds;
+ i = (size_t)(job->inPollfd - fds);
nfds--;
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
if (useMeta) {
@@ -2638,7 +2638,7 @@
Job_TokenWithdraw(void)
{
char tok, tok1;
- int count;
+ ssize_t count;
wantToken = 0;
DEBUG3(JOB, "Job_TokenWithdraw(%d): aborting %d, running %d\n",
diff -r be08af460222 -r b0c80b83b37a usr.bin/make/job.h
--- a/usr.bin/make/job.h Mon Oct 05 21:11:47 2020 +0000
+++ b/usr.bin/make/job.h Mon Oct 05 21:37:07 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.h,v 1.54 2020/09/28 00:13:03 rillig Exp $ */
+/* $NetBSD: job.h,v 1.55 2020/10/05 21:37:07 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -154,7 +154,7 @@
char job_suspended;
- short flags; /* Flags to control treatment of job */
+ int flags; /* Flags to control treatment of job */
#define JOB_IGNERR 0x001 /* Ignore non-zero exits */
#define JOB_SILENT 0x002 /* no output */
#define JOB_SPECIAL 0x004 /* Target is a special one. i.e. run it locally
@@ -170,7 +170,7 @@
#define JOB_BUFSIZE 1024
/* Buffer for storing the output of the job, line by line. */
char outBuf[JOB_BUFSIZE + 1];
- int curPos; /* Current position in outBuf. */
+ size_t curPos; /* Current position in outBuf. */
#ifdef USE_META
struct BuildMon bm;
diff -r be08af460222 -r b0c80b83b37a usr.bin/make/main.c
--- a/usr.bin/make/main.c Mon Oct 05 21:11:47 2020 +0000
+++ b/usr.bin/make/main.c Mon Oct 05 21:37:07 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.369 2020/10/05 19:27:47 rillig Exp $ */
+/* $NetBSD: main.c,v 1.370 2020/10/05 21:37:07 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -122,7 +122,7 @@
#endif
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.369 2020/10/05 19:27:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.370 2020/10/05 21:37:07 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -443,7 +443,7 @@
char *p;
forceJobs = TRUE;
- maxJobs = strtol(argvalue, &p, 0);
+ maxJobs = (int)strtol(argvalue, &p, 0);
if (*p != '\0' || maxJobs < 1) {
(void)fprintf(stderr,
"%s: illegal argument to -j -- must be positive integer!\n",
@@ -1073,7 +1073,7 @@
* on each program execution.
*/
gettimeofday(&rightnow, NULL);
- srandom(rightnow.tv_sec + rightnow.tv_usec);
+ srandom((unsigned int)(rightnow.tv_sec + rightnow.tv_usec));
if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
@@ -1419,7 +1419,7 @@
(void)Var_Subst("${.MAKE.JOBS}", VAR_GLOBAL, VARE_WANTRES, &value);
/* TODO: handle errors */
- n = strtol(value, NULL, 0);
+ n = (int)strtol(value, NULL, 0);
if (n < 1) {
(void)fprintf(stderr, "%s: illegal value for .MAKE.JOBS -- must be positive integer!\n",
progname);
diff -r be08af460222 -r b0c80b83b37a usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Mon Oct 05 21:11:47 2020 +0000
+++ b/usr.bin/make/parse.c Mon Oct 05 21:37:07 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.368 2020/10/05 19:27:47 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.369 2020/10/05 21:37:07 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.368 2020/10/05 19:27:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.369 2020/10/05 21:37:07 rillig Exp $");
/* types and constants */
@@ -143,7 +143,7 @@
Boolean fromForLoop; /* simulated .include by the .for loop */
int lineno; /* current line number in file */
int first_lineno; /* line number of start of text */
- int cond_depth; /* 'if' nesting when file opened */
+ unsigned int cond_depth; /* 'if' nesting when file opened */
Boolean depending; /* state of doing_depend on EOF */
char *P_str; /* point to base of string buffer */
char *P_ptr; /* point to next char of string buffer */
@@ -454,7 +454,7 @@
loadfile(const char *path, int fd)
{
struct loadedfile *lf;
- static long pagesize = 0;
+ static unsigned long pagesize = 0;
ssize_t result;
size_t bufpos;
@@ -477,8 +477,8 @@
if (load_getsize(fd, &lf->len)) {
/* found a size, try mmap */
if (pagesize == 0)
- pagesize = sysconf(_SC_PAGESIZE);
- if (pagesize <= 0) {
+ pagesize = (unsigned long)sysconf(_SC_PAGESIZE);
+ if (pagesize == 0 || pagesize == (unsigned long)-1) {
pagesize = 0x1000;
}
/* round size up to a page */
@@ -540,7 +540,7 @@
if (result == 0) {
break;
}
- bufpos += result;
+ bufpos += (size_t)result;
}
assert(bufpos <= lf->len);
lf->len = bufpos;
@@ -709,7 +709,7 @@
lineno = 0;
} else {
fname = curFile->fname;
- lineno = curFile->lineno;
+ lineno = (size_t)curFile->lineno;
}
va_start(ap, fmt);
@@ -2113,7 +2113,7 @@
Home |
Main Index |
Thread Index |
Old Index