Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint lint: fix some more lint warnings



details:   https://anonhg.NetBSD.org/src/rev/e074f33b2c50
branches:  trunk
changeset: 1023389:e074f33b2c50
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Sep 05 16:15:05 2021 +0000

description:
lint: fix some more lint warnings

The only remaining warnings are in scan.c, which is a generated Flex
scanner.

No functional change.

diffstat:

 usr.bin/xlint/lint1/decl.c  |   6 ++++--
 usr.bin/xlint/lint1/err.c   |   8 ++++----
 usr.bin/xlint/lint2/read.c  |  15 ++++++++-------
 usr.bin/xlint/xlint/xlint.c |   6 +++---
 4 files changed, 19 insertions(+), 16 deletions(-)

diffs (168 lines):

diff -r 3a17f7e5eb99 -r e074f33b2c50 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sun Sep 05 16:03:55 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sun Sep 05 16:15:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.234 2021/09/05 16:03:55 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.235 2021/09/05 16:15:05 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.234 2021/09/05 16:03:55 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.235 2021/09/05 16:15:05 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -140,6 +140,7 @@
        typetab[LCOMPLEX].t_tspec = LCOMPLEX;
 }
 
+#ifdef DEBUG
 /* Return the name of the "storage class" in the wider sense. */
 const char *
 scl_name(scl_t scl)
@@ -153,6 +154,7 @@
 
        return names[scl];
 }
+#endif
 
 /*
  * Returns a shared type structure for arithmetic types and void.
diff -r 3a17f7e5eb99 -r e074f33b2c50 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Sep 05 16:03:55 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Sep 05 16:15:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.143 2021/09/05 13:19:39 rillig Exp $ */
+/*     $NetBSD: err.c,v 1.144 2021/09/05 16:15:05 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.143 2021/09/05 13:19:39 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.144 2021/09/05 16:15:05 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -572,7 +572,7 @@
        const   char *fn;
 
        fn = lbasename(curr_pos.p_file);
-       fflush(stdout);
+       (void)fflush(stdout);
        (void)fprintf(stderr, "lint: internal error in %s:%d near %s:%d: ",
            file, line, fn, curr_pos.p_line);
        va_start(ap, msg);
@@ -589,7 +589,7 @@
        const   char *fn;
 
        fn = lbasename(curr_pos.p_file);
-       fflush(stdout);
+       (void)fflush(stdout);
        (void)fprintf(stderr,
            "lint: assertion \"%s\" failed in %s at %s:%d near %s:%d\n",
            cond, func, file, line, fn, curr_pos.p_line);
diff -r 3a17f7e5eb99 -r e074f33b2c50 usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c        Sun Sep 05 16:03:55 2021 +0000
+++ b/usr.bin/xlint/lint2/read.c        Sun Sep 05 16:15:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.64 2021/09/04 19:16:38 rillig Exp $ */
+/* $NetBSD: read.c,v 1.65 2021/09/05 16:15:05 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: read.c,v 1.64 2021/09/04 19:16:38 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.65 2021/09/05 16:15:05 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -100,7 +100,7 @@
 static void    decldef(pos_t *, const char *);
 static void    usedsym(pos_t *, const char *);
 static unsigned short inptype(const char *, const char **);
-static int     gettlen(const char *, const char **);
+static size_t  gettlen(const char *, const char **);
 static unsigned short findtype(const char *, size_t, int);
 static unsigned short storetyp(type_t *, const char *, size_t, int);
 static int     thash(const char *, size_t);
@@ -621,6 +621,7 @@
                                       : (s == 'l' ? LCOMPLEX : DCOMPLEX);
        default:
                inperr("tspec '%c'", c);
+               /* NOTREACHED */
        }
 }
 
@@ -730,7 +731,7 @@
 /*
  * Get the length of a type string.
  */
-static int
+static size_t
 gettlen(const char *cp, const char **epp)
 {
        const   char *cp1;
@@ -913,7 +914,7 @@
        }
 
        *epp = cp;
-       return cp - cp1;
+       return (size_t)(cp - cp1);
 }
 
 /*
@@ -1107,7 +1108,7 @@
        /* 0 is reserved */
        for (i = 1; fnames[i] != NULL; i++) {
                if (strcmp(fnames[i], fn) == 0)
-                       return i;
+                       return (int)i;
        }
 
        if (i == nfnames - 1) {
@@ -1121,7 +1122,7 @@
 
        fnames[i] = xstrdup(fn);
        flines[i] = 0;
-       return i;
+       return (int)i;
 }
 
 /*
diff -r 3a17f7e5eb99 -r e074f33b2c50 usr.bin/xlint/xlint/xlint.c
--- a/usr.bin/xlint/xlint/xlint.c       Sun Sep 05 16:03:55 2021 +0000
+++ b/usr.bin/xlint/xlint/xlint.c       Sun Sep 05 16:15:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.80 2021/08/28 14:42:29 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.81 2021/09/05 16:15:05 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.80 2021/08/28 14:42:29 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.81 2021/09/05 16:15:05 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -745,7 +745,7 @@
 
                /* setup the standard output if necessary */
                if (fdout != -1) {
-                       dup2(fdout, STDOUT_FILENO);
+                       (void)dup2(fdout, STDOUT_FILENO);
                        (void)close(fdout);
                }
                (void)execvp(path, args);



Home | Main Index | Thread Index | Old Index