Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: rename olwarn and LWARN_BAD to be ...



details:   https://anonhg.NetBSD.org/src/rev/e79eb4f49921
branches:  trunk
changeset: 366425:e79eb4f49921
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu May 26 13:40:49 2022 +0000

description:
lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  24 +++++++++++++-----------
 usr.bin/xlint/lint1/decl.c  |  10 +++++-----
 usr.bin/xlint/lint1/func.c  |  19 ++++++++++---------
 usr.bin/xlint/lint1/lint1.h |   4 ++--
 4 files changed, 30 insertions(+), 27 deletions(-)

diffs (176 lines):

diff -r 841ab14ad419 -r e79eb4f49921 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Thu May 26 13:02:04 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Thu May 26 13:40:49 2022 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.418 2022/05/26 12:47:20 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.419 2022/05/26 13:40:49 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.418 2022/05/26 12:47:20 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.419 2022/05/26 13:40:49 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -64,7 +64,8 @@
  * Save the no-warns state and restore it to avoid the problem where
  * if (expr) { stmt } / * NOLINT * / stmt;
  */
-static int olwarn = LWARN_BAD;
+#define LWARN_NOTHING_SAVED (-3)
+static int saved_lwarn = LWARN_NOTHING_SAVED;
 
 static void    cgram_declare(sym_t *, bool, sbuf_t *);
 static void    read_until_rparen(void);
@@ -77,7 +78,7 @@
 {
        debug_step("%s:%zu: clearing flags", file, line);
        clear_warn_flags();
-       olwarn = LWARN_BAD;
+       saved_lwarn = LWARN_NOTHING_SAVED;
 }
 
 /* ARGSUSED */
@@ -85,8 +86,9 @@
 save_warning_flags_loc(const char *file, size_t line)
 {
        /*
-        * There used to be an assertion for 'olwarn == LWARN_BAD' here,
-        * but that triggered for the following code:
+        * There used to be an assertion that saved_lwarn is
+        * LWARN_NOTHING_SAVED here, but that triggered for the following
+        * code:
         *
         * void function(int x) { if (x > 0) if (x > 1) return; }
         *
@@ -96,19 +98,19 @@
         *  warnings.
         */
        debug_step("%s:%zu: saving flags %d", file, line, lwarn);
-       olwarn = lwarn;
+       saved_lwarn = lwarn;
 }
 
 /* ARGSUSED */
 static void
 restore_warning_flags_loc(const char *file, size_t line)
 {
-       if (olwarn != LWARN_BAD) {
-               lwarn = olwarn;
+       if (saved_lwarn != LWARN_NOTHING_SAVED) {
+               lwarn = saved_lwarn;
                debug_step("%s:%zu: restoring flags %d", file, line, lwarn);
                /*
-                * Do not set 'olwarn = LWARN_BAD' here, to avoid triggering
-                * the assertion in save_warning_flags_loc.
+                * Do not set 'saved_lwarn = LWARN_NOTHING_SAVED' here, to
+                * avoid triggering the assertion in save_warning_flags_loc.
                 */
        } else
                clear_warning_flags_loc(file, line);
diff -r 841ab14ad419 -r e79eb4f49921 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Thu May 26 13:02:04 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Thu May 26 13:40:49 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.281 2022/05/20 21:18:55 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.282 2022/05/26 13:40:49 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.281 2022/05/20 21:18:55 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.282 2022/05/26 13:40:49 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -3048,16 +3048,16 @@
 check_usage(dinfo_t *di)
 {
        sym_t   *sym;
-       int     mklwarn;
+       int     saved_lwarn;
 
        /* for this warning LINTED has no effect */
-       mklwarn = lwarn;
+       saved_lwarn = lwarn;
        lwarn = LWARN_ALL;
 
        debug_step("begin lwarn %d", lwarn);
        for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_level_next)
                check_usage_sym(di->d_asm, sym);
-       lwarn = mklwarn;
+       lwarn = saved_lwarn;
        debug_step("end lwarn %d", lwarn);
 }
 
diff -r 841ab14ad419 -r e79eb4f49921 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Thu May 26 13:02:04 2022 +0000
+++ b/usr.bin/xlint/lint1/func.c        Thu May 26 13:40:49 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.137 2022/05/22 13:58:59 rillig Exp $        */
+/*     $NetBSD: func.c,v 1.138 2022/05/26 13:40:49 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.137 2022/05/22 13:58:59 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.138 2022/05/26 13:40:49 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -122,18 +122,19 @@
 bool   constcond_flag;
 
 /*
- * llibflg is set if a lint library shall be created. The effect of
- * llibflg is that all defined symbols are treated as used.
+ * Whether a lint library shall be created. The effect of this flag is that
+ * all defined symbols are treated as used.
  * (The LINTLIBRARY comment also resets vflag.)
  */
 bool   llibflg;
 
 /*
- * Nonzero if warnings are suppressed by a LINTED directive
- * LWARN_BAD:  error
- * LWARN_ALL:  warnings on
- * LWARN_NONE: all warnings ignored
- * 0..n: warning n ignored
+ * Determines the warnings that are suppressed by a LINTED directive.  For
+ * globally suppressed warnings, see 'msgset'.
+ *
+ * LWARN_ALL:  all warnings are enabled
+ * LWARN_NONE: all warnings are suppressed
+ * n >= 0:     warning n is ignored, the others are active
  */
 int    lwarn = LWARN_ALL;
 
diff -r 841ab14ad419 -r e79eb4f49921 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Thu May 26 13:02:04 2022 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Thu May 26 13:40:49 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.153 2022/04/16 20:57:10 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.154 2022/05/26 13:40:49 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -36,7 +36,7 @@
 #include "err-msgs.h"
 #include "op.h"
 
-#define LWARN_BAD      (-3)
+/* See saved_lwarn in cgram.y. */
 #define LWARN_ALL      (-2)
 #define LWARN_NONE     (-1)
 



Home | Main Index | Thread Index | Old Index