Module Name:    src
Committed By:   rillig
Date:           Sun Sep  5 16:15:06 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: decl.c err.c
        src/usr.bin/xlint/lint2: read.c
        src/usr.bin/xlint/xlint: xlint.c

Log Message:
lint: fix some more lint warnings

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

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.143 -r1.144 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.64 -r1.65 src/usr.bin/xlint/lint2/read.c
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/xlint/xlint.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/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.234 src/usr.bin/xlint/lint1/decl.c:1.235
--- src/usr.bin/xlint/lint1/decl.c:1.234	Sun Sep  5 16:03:55 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sun Sep  5 16:15:05 2021
@@ -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 @@ initdecl(void)
 	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 @@ scl_name(scl_t scl)
 
 	return names[scl];
 }
+#endif
 
 /*
  * Returns a shared type structure for arithmetic types and void.

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.143 src/usr.bin/xlint/lint1/err.c:1.144
--- src/usr.bin/xlint/lint1/err.c:1.143	Sun Sep  5 13:19:39 2021
+++ src/usr.bin/xlint/lint1/err.c	Sun Sep  5 16:15:05 2021
@@ -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 @@ internal_error(const char *file, int lin
 	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 @@ assert_failed(const char *file, int line
 	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);

Index: src/usr.bin/xlint/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.64 src/usr.bin/xlint/lint2/read.c:1.65
--- src/usr.bin/xlint/lint2/read.c:1.64	Sat Sep  4 19:16:38 2021
+++ src/usr.bin/xlint/lint2/read.c	Sun Sep  5 16:15:05 2021
@@ -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	funccall(pos_t *, const char
 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 @@ parse_tspec(const char **pp, char c, boo
 				       : (s == 'l' ? LCOMPLEX : DCOMPLEX);
 	default:
 		inperr("tspec '%c'", c);
+		/* NOTREACHED */
 	}
 }
 
@@ -730,7 +731,7 @@ inptype(const char *cp, const char **epp
 /*
  * 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 @@ gettlen(const char *cp, const char **epp
 	}
 
 	*epp = cp;
-	return cp - cp1;
+	return (size_t)(cp - cp1);
 }
 
 /*
@@ -1107,7 +1108,7 @@ getfnidx(const char *fn)
 	/* 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 @@ getfnidx(const char *fn)
 
 	fnames[i] = xstrdup(fn);
 	flines[i] = 0;
-	return i;
+	return (int)i;
 }
 
 /*

Index: src/usr.bin/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.80 src/usr.bin/xlint/xlint/xlint.c:1.81
--- src/usr.bin/xlint/xlint/xlint.c:1.80	Sat Aug 28 14:42:29 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Sep  5 16:15:05 2021
@@ -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 @@ runchild(const char *path, char *const *
 
 		/* 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);

Reply via email to