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 for WARNS=6



details:   https://anonhg.NetBSD.org/src/rev/b10cfeec908e
branches:  trunk
changeset: 1015232:b10cfeec908e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 18 11:54:43 2020 +0000

description:
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.

diffstat:

 usr.bin/make/filemon/filemon_ktrace.c |  12 ++++++------
 usr.bin/make/main.c                   |   6 +++---
 usr.bin/make/meta.c                   |  29 +++++++++++++++--------------
 3 files changed, 24 insertions(+), 23 deletions(-)

diffs (193 lines):

diff -r facc2d640dff -r b10cfeec908e usr.bin/make/filemon/filemon_ktrace.c
--- a/usr.bin/make/filemon/filemon_ktrace.c     Sun Oct 18 11:54:20 2020 +0000
+++ b/usr.bin/make/filemon/filemon_ktrace.c     Sun Oct 18 11:54:43 2020 +0000
@@ -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 @@
                 */
                /* 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 @@
     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 @@
 
        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 @@
 
        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)
diff -r facc2d640dff -r b10cfeec908e usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Oct 18 11:54:20 2020 +0000
+++ b/usr.bin/make/main.c       Sun Oct 18 11:54:43 2020 +0000
@@ -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 @@
                if (written == -1)
                        break;
                mem += written;
-               n -= written;
+               n -= (size_t)written;
        }
 }
 
diff -r facc2d640dff -r b10cfeec908e usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sun Oct 18 11:54:20 2020 +0000
+++ b/usr.bin/make/meta.c       Sun Oct 18 11:54:43 2020 +0000
@@ -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 @@
 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 @@
        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 @@
                } 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 @@
                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 @@
 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 @@
     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 @@
                                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 @@
     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 @@
            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 @@
                *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 @@
 
            /* 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 */
                }
            }



Home | Main Index | Thread Index | Old Index