Module Name: src Committed By: rillig Date: Sun Oct 18 11:54:43 UTC 2020
Modified Files: src/usr.bin/make: main.c meta.c src/usr.bin/make/filemon: filemon_ktrace.c Log Message: make(1): prepare for WARNS=6 The FD_* macros from sys/sys/fd_set.h use signed integers on NetBSD 8 and thus produce conversion errors. On NetBSD 9, these macros are fixed to use 1U instead of 1. To generate a diff of this commit: cvs rdiff -u -r1.374 -r1.375 src/usr.bin/make/main.c cvs rdiff -u -r1.123 -r1.124 src/usr.bin/make/meta.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/filemon/filemon_ktrace.c 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/main.c diff -u src/usr.bin/make/main.c:1.374 src/usr.bin/make/main.c:1.375 --- src/usr.bin/make/main.c:1.374 Sun Oct 18 10:44:25 2020 +++ src/usr.bin/make/main.c Sun Oct 18 11:54:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.374 2020/10/18 10:44:25 rillig Exp $ */ +/* $NetBSD: main.c,v 1.375 2020/10/18 11:54:43 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -118,7 +118,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.374 2020/10/18 10:44:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.375 2020/10/18 11:54:43 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1884,7 +1884,7 @@ write_all(int fd, const void *data, size if (written == -1) break; mem += written; - n -= written; + n -= (size_t)written; } } Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.123 src/usr.bin/make/meta.c:1.124 --- src/usr.bin/make/meta.c:1.123 Sun Oct 18 07:46:04 2020 +++ src/usr.bin/make/meta.c Sun Oct 18 11:54:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.123 2020/10/18 07:46:04 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.124 2020/10/18 11:54:43 rillig Exp $ */ /* * Implement 'meta' mode. @@ -161,7 +161,6 @@ static int filemon_read(FILE *mfp, int fd) { char buf[BUFSIZ]; - int n; int error; /* Check if we're not writing to a meta data file.*/ @@ -176,11 +175,13 @@ filemon_read(FILE *mfp, int fd) warn("Could not rewind filemon"); fprintf(mfp, "\n"); } else { + ssize_t n; + error = 0; fprintf(mfp, "\n-- filemon acquired metadata --\n"); while ((n = read(fd, buf, sizeof(buf))) > 0) { - if ((int)fwrite(buf, 1, n, mfp) < n) + if ((ssize_t)fwrite(buf, 1, (size_t)n, mfp) < n) error = EIO; } } @@ -226,7 +227,7 @@ eat_dots(char *buf, size_t bufsz, int do } while (cp > buf && *cp != '/'); } if (*cp == '/') { - strlcpy(cp, cp2, bufsz - (cp - buf)); + strlcpy(cp, cp2, bufsz - (size_t)(cp - buf)); } else { return; /* can't happen? */ } @@ -260,7 +261,7 @@ meta_name(struct GNode *gn, char *mname, rp++; cp++; if (strcmp(cp, rp) != 0) - strlcpy(rp, cp, sizeof(buf) - (rp - buf)); + strlcpy(rp, cp, sizeof buf - (size_t)(rp - buf)); } tname = buf; } else { @@ -316,7 +317,7 @@ static int is_submake(void *cmdp, void *gnp) { static const char *p_make = NULL; - static int p_len; + static size_t p_len; char *cmd = cmdp; GNode *gn = gnp; char *mp = NULL; @@ -809,7 +810,7 @@ meta_job_output(Job *job, char *cp, cons if (pbm->mfp != NULL) { if (metaVerbose) { static char *meta_prefix = NULL; - static int meta_prefix_len; + static size_t meta_prefix_len; if (!meta_prefix) { char *cp2; @@ -818,7 +819,7 @@ meta_job_output(Job *job, char *cp, cons VAR_GLOBAL, VARE_WANTRES, &meta_prefix); /* TODO: handle errors */ if ((cp2 = strchr(meta_prefix, '$'))) - meta_prefix_len = cp2 - meta_prefix; + meta_prefix_len = (size_t)(cp2 - meta_prefix); else meta_prefix_len = strlen(meta_prefix); } @@ -907,9 +908,9 @@ fgetLine(char **bufp, size_t *szp, int o struct stat fs; int x; - if (fgets(&buf[o], bufsz - o, fp) != NULL) { + if (fgets(&buf[o], (int)bufsz - o, fp) != NULL) { check_newline: - x = o + strlen(&buf[o]); + x = o + (int)strlen(&buf[o]); if (buf[x - 1] == '\n') return x; /* @@ -920,9 +921,9 @@ fgetLine(char **bufp, size_t *szp, int o size_t newsz; char *p; - newsz = ROUNDUP((fs.st_size / 2), BUFSIZ); + newsz = ROUNDUP(((size_t)fs.st_size / 2), BUFSIZ); if (newsz <= bufsz) - newsz = ROUNDUP(fs.st_size, BUFSIZ); + newsz = ROUNDUP((size_t)fs.st_size, BUFSIZ); if (newsz <= bufsz) return x; /* truncated */ DEBUG2(META, "growing buffer %zu -> %zu\n", bufsz, newsz); @@ -931,7 +932,7 @@ fgetLine(char **bufp, size_t *szp, int o *bufp = buf = p; *szp = bufsz = newsz; /* fetch the rest */ - if (!fgets(&buf[x], bufsz - x, fp)) + if (!fgets(&buf[x], (int)bufsz - x, fp)) return x; /* truncated! */ goto check_newline; } @@ -1584,7 +1585,7 @@ meta_oodate(GNode *gn, Boolean oodate) /* if target is in .CURDIR we do not need a meta file */ if (gn->path && (cp = strrchr(gn->path, '/')) && cp > gn->path) { - if (strncmp(curdir, gn->path, (cp - gn->path)) != 0) { + if (strncmp(curdir, gn->path, (size_t)(cp - gn->path)) != 0) { cp = NULL; /* not in .CURDIR */ } } Index: src/usr.bin/make/filemon/filemon_ktrace.c diff -u src/usr.bin/make/filemon/filemon_ktrace.c:1.2 src/usr.bin/make/filemon/filemon_ktrace.c:1.3 --- src/usr.bin/make/filemon/filemon_ktrace.c:1.2 Sun Jan 19 20:22:57 2020 +++ src/usr.bin/make/filemon/filemon_ktrace.c Sun Oct 18 11:54:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: filemon_ktrace.c,v 1.2 2020/01/19 20:22:57 riastradh Exp $ */ +/* $NetBSD: filemon_ktrace.c,v 1.3 2020/10/18 11:54:43 rillig Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -478,7 +478,7 @@ filemon_dispatch(struct filemon *F) */ /* XXX What to do if syscall code doesn't match? */ if (S->i == S->npath && S->syscode == ret->ktr_code) - (*S->show)(F, S, ret); + S->show(F, S, ret); /* Free the state now that it is no longer active. */ for (i = 0; i < S->i; i++) @@ -771,7 +771,7 @@ filemon_sys_exit(struct filemon *F, cons const struct ktr_syscall *call) { const register_t *args = (const void *)&call[1]; - int status = args[0]; + int status = (int)args[0]; if (F->out) { fprintf(F->out, "X %jd %d\n", (intmax_t)key->pid, status); @@ -806,7 +806,7 @@ filemon_sys_open(struct filemon *F, cons if (call->ktr_argsize < 2) return NULL; - flags = args[1]; + flags = (int)args[1]; if ((flags & O_RDWR) == O_RDWR) return syscall_enter(F, key, call, 1, &show_open_readwrite); @@ -827,8 +827,8 @@ filemon_sys_openat(struct filemon *F, co if (call->ktr_argsize < 3) return NULL; - fd = args[0]; - flags = args[2]; + fd = (int)args[0]; + flags = (int)args[2]; if (fd == AT_CWD) { if ((flags & O_RDWR) == O_RDWR)