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: explicitly ignore return value of some f...



details:   https://anonhg.NetBSD.org/src/rev/4467b22f12d7
branches:  trunk
changeset: 1023166:4467b22f12d7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 28 13:29:26 2021 +0000

description:
lint: explicitly ignore return value of some function calls

This fixes the warning from lint2 that these functions return values
which are sometimes ignored.

The remaining calls to fprintf that ignore the return value come from
scan.c.  Lint does not currently detect the auto-generated portions of
that file and the interesting ones since it assumes that scan.c is the
main filename, see expr_zalloc_tnode.

No functional change.

diffstat:

 usr.bin/xlint/common/mem.c    |   6 +++---
 usr.bin/xlint/common/tyname.c |   6 +++---
 usr.bin/xlint/lint1/cgram.y   |   6 +++---
 usr.bin/xlint/lint1/func.c    |   6 +++---
 usr.bin/xlint/lint1/lex.c     |   6 +++---
 usr.bin/xlint/lint1/main1.c   |  12 ++++++------
 usr.bin/xlint/lint1/mem1.c    |   6 +++---
 7 files changed, 24 insertions(+), 24 deletions(-)

diffs (212 lines):

diff -r ffaac9102802 -r 4467b22f12d7 usr.bin/xlint/common/mem.c
--- a/usr.bin/xlint/common/mem.c        Sat Aug 28 13:11:10 2021 +0000
+++ b/usr.bin/xlint/common/mem.c        Sat Aug 28 13:29:26 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem.c,v 1.17 2021/08/22 15:06:49 rillig Exp $  */
+/*     $NetBSD: mem.c,v 1.18 2021/08/28 13:29:26 rillig Exp $  */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem.c,v 1.17 2021/08/22 15:06:49 rillig Exp $");
+__RCSID("$NetBSD: mem.c,v 1.18 2021/08/28 13:29:26 rillig Exp $");
 #endif
 
 #include <stdarg.h>
@@ -95,7 +95,7 @@
        e = vasprintf(&str, fmt, ap);
        va_end(ap);
        if (e < 0)
-               not_null(NULL);
+               (void)not_null(NULL);
        return str;
 }
 #endif
diff -r ffaac9102802 -r 4467b22f12d7 usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c     Sat Aug 28 13:11:10 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c     Sat Aug 28 13:29:26 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tyname.c,v 1.44 2021/08/03 17:44:58 rillig Exp $       */
+/*     $NetBSD: tyname.c,v 1.45 2021/08/28 13:29:26 rillig Exp $       */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.44 2021/08/03 17:44:58 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.45 2021/08/28 13:29:26 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -143,7 +143,7 @@
 {
        char num[1 + sizeof(n) * CHAR_BIT + 1];
 
-       snprintf(num, sizeof(num), "%d", n);
+       (void)snprintf(num, sizeof(num), "%d", n);
        buf_add(buf, num);
 }
 
diff -r ffaac9102802 -r 4467b22f12d7 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Aug 28 13:11:10 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sat Aug 28 13:29:26 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.358 2021/08/25 22:48:40 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.359 2021/08/28 13:29:26 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.358 2021/08/25 22:48:40 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.359 2021/08/28 13:29:26 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -2166,7 +2166,7 @@
 static void
 cgram_print(FILE *output, int token, YYSTYPE val)
 {
-       fprintf(output, "%s", cgram_to_string(token, val));
+       (void)fprintf(output, "%s", cgram_to_string(token, val));
 }
 #endif
 
diff -r ffaac9102802 -r 4467b22f12d7 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Sat Aug 28 13:11:10 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c        Sat Aug 28 13:29:26 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.121 2021/08/28 12:21:53 rillig Exp $        */
+/*     $NetBSD: func.c,v 1.122 2021/08/28 13:29:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.121 2021/08/28 12:21:53 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.122 2021/08/28 13:29:26 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -718,7 +718,7 @@
        }
 
        /* leak the memory, for check_case_label_bitand */
-       expr_save_memory();
+       (void)expr_save_memory();
 
        check_getopt_begin_switch();
        expr(tn, true, false, false, false);
diff -r ffaac9102802 -r 4467b22f12d7 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Aug 28 13:11:10 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Aug 28 13:29:26 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.72 2021/08/28 13:11:10 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.73 2021/08/28 13:29:26 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: lex.c,v 1.72 2021/08/28 13:11:10 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.73 2021/08/28 13:29:26 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -295,7 +295,7 @@
        if (!leading && !trailing) {
                name = kw->kw_name;
        } else {
-               snprintf(buf, sizeof(buf), "%s%s%s",
+               (void)snprintf(buf, sizeof(buf), "%s%s%s",
                    leading ? "__" : "", kw->kw_name, trailing ? "__" : "");
                name = xstrdup(buf);
        }
diff -r ffaac9102802 -r 4467b22f12d7 usr.bin/xlint/lint1/main1.c
--- a/usr.bin/xlint/lint1/main1.c       Sat Aug 28 13:11:10 2021 +0000
+++ b/usr.bin/xlint/lint1/main1.c       Sat Aug 28 13:29:26 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main1.c,v 1.56 2021/08/17 22:29:11 rillig Exp $        */
+/*     $NetBSD: main1.c,v 1.57 2021/08/28 13:29:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.56 2021/08/17 22:29:11 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.57 2021/08/28 13:29:26 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -147,11 +147,11 @@
                return NULL;
        (void)unlink(template);
        if ((fp = fdopen(fd, "r+")) == NULL) {
-               close(fd);
+               (void)close(fd);
                return NULL;
        }
        if (fwrite(builtins, 1, builtins_len, fp) != builtins_len) {
-               fclose(fp);
+               (void)fclose(fp);
                return NULL;
        }
        rewind(fp);
@@ -267,14 +267,14 @@
                if ((yyin = gcc_builtins()) == NULL)
                        err(1, "cannot open builtins");
                yyparse();
-               fclose(yyin);
+               (void)fclose(yyin);
        }
 
        /* open the input file */
        if ((yyin = fopen(argv[0], "r")) == NULL)
                err(1, "cannot open '%s'", argv[0]);
        yyparse();
-       fclose(yyin);
+       (void)fclose(yyin);
 
        /* Following warnings cannot be suppressed by LINTED */
        lwarn = LWARN_ALL;
diff -r ffaac9102802 -r 4467b22f12d7 usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c        Sat Aug 28 13:11:10 2021 +0000
+++ b/usr.bin/xlint/lint1/mem1.c        Sat Aug 28 13:29:26 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem1.c,v 1.50 2021/08/28 12:59:25 rillig Exp $ */
+/*     $NetBSD: mem1.c,v 1.51 2021/08/28 13:29:26 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.50 2021/08/28 12:59:25 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.51 2021/08/28 13:29:26 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -112,7 +112,7 @@
                        break;
        if (r == NULL)
                return name;
-       snprintf(buf, sizeof(buf), "%s%s", r->repl, name + r->orig_len);
+       (void)snprintf(buf, sizeof(buf), "%s%s", r->repl, name + r->orig_len);
        return buf;
 }
 



Home | Main Index | Thread Index | Old Index