Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint2 lint: revert "remove redundant call to s...



details:   https://anonhg.NetBSD.org/src/rev/79d1e9701ff0
branches:  trunk
changeset: 985568:79d1e9701ff0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Aug 30 19:07:57 2021 +0000

description:
lint: revert "remove redundant call to strchr" from yesterday

This "refactoring" broke the parsing code for varargs, printflike and
scanflike functions, and there were no tests for these.  Revert for now,
maybe try again later, after adding the corresponding tests.

diffstat:

 tests/usr.bin/xlint/lint2/read.exp |   1 +
 tests/usr.bin/xlint/lint2/read.ln  |   7 ++++++-
 usr.bin/xlint/lint2/read.c         |  37 ++++++++++++++++---------------------
 3 files changed, 23 insertions(+), 22 deletions(-)

diffs (138 lines):

diff -r ef1282aa8063 -r 79d1e9701ff0 tests/usr.bin/xlint/lint2/read.exp
--- a/tests/usr.bin/xlint/lint2/read.exp        Mon Aug 30 19:01:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/read.exp        Mon Aug 30 19:07:57 2021 +0000
@@ -1,1 +1,2 @@
 a125 declared( read.c(125) ), but never used or defined
+bpf_set_error defined( read.c(400) ), but never used
diff -r ef1282aa8063 -r 79d1e9701ff0 tests/usr.bin/xlint/lint2/read.ln
--- a/tests/usr.bin/xlint/lint2/read.ln Mon Aug 30 19:01:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/read.ln Mon Aug 30 19:07:57 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: read.ln,v 1.2 2021/08/24 23:38:51 rillig Exp $
+# $NetBSD: read.ln,v 1.3 2021/08/30 19:07:57 rillig Exp $
 #
 # Cover each path of reading declarations, definitions and usages.
 
@@ -62,3 +62,8 @@
 302 d 0.302 e 4f302 F1 PvI V
 # void f302(const volatile int *);
 303 d 0.303 e 4f303 F1 PcvI V
+
+# The "cleanup" in read.c 1.58 produced "not a number: v0...".
+# The corresponding tests for parsing vararg, printflike and scanflike are
+# still missing, that's why it got through unnoticed.
+400 d 0.439 v0 d 13bpf_set_error F3 PsT115_compiler_state PcC E V
diff -r ef1282aa8063 -r 79d1e9701ff0 usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c        Mon Aug 30 19:01:05 2021 +0000
+++ b/usr.bin/xlint/lint2/read.c        Mon Aug 30 19:07:57 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.60 2021/08/30 18:03:52 christos Exp $ */
+/* $NetBSD: read.c,v 1.61 2021/08/30 19:07:57 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.60 2021/08/30 18:03:52 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.61 2021/08/30 19:07:57 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -136,12 +136,7 @@
 static short
 parse_short(const char **p)
 {
-
-       short s;
-       (*p)++;
-       s = (short)parse_int(p);
-       (*p)--;
-       return s;
+       return (short)parse_int(p);
 }
 
 void
@@ -392,68 +387,68 @@
 
        used = false;
 
-       for (; (c = *cp) != '\0'; cp++) {
+       while (strchr("deiorstuvPS", (c = *cp)) != NULL) {
+               cp++;
                switch (c) {
                case 'd':
                        if (sym.s_def != NODECL)
                                inperr("def");
                        sym.s_def = DEF;
-                       continue;
+                       break;
                case 'e':
                        if (sym.s_def != NODECL)
                                inperr("decl");
                        sym.s_def = DECL;
-                       continue;
+                       break;
                case 'i':
                        if (sym.s_inline)
                                inperr("inline");
                        sym.s_inline = true;
-                       continue;
+                       break;
                case 'o':
                        if (sym.s_old_style_function)
                                inperr("osdef");
                        sym.s_old_style_function = true;
-                       continue;
+                       break;
                case 'r':
                        if (sym.s_function_has_return_value)
                                inperr("r");
                        sym.s_function_has_return_value = true;
-                       continue;
+                       break;
                case 's':
                        if (sym.s_static)
                                inperr("static");
                        sym.s_static = true;
-                       continue;
+                       break;
                case 't':
                        if (sym.s_def != NODECL)
                                inperr("tdef");
                        sym.s_def = TDEF;
-                       continue;
+                       break;
                case 'u':
                        if (used)
                                inperr("used");
                        used = true;
-                       continue;
+                       break;
                case 'v':
                        if (sym.s_check_only_first_args)
                                inperr("v");
                        sym.s_check_only_first_args = true;
                        sym.s_check_num_args = parse_short(&cp);
-                       continue;
+                       break;
                case 'P':
                        if (sym.s_printflike)
                                inperr("P");
                        sym.s_printflike = true;
                        sym.s_printflike_arg = parse_short(&cp);
-                       continue;
+                       break;
                case 'S':
                        if (sym.s_scanflike)
                                inperr("S");
                        sym.s_scanflike = true;
                        sym.s_scanflike_arg = parse_short(&cp);
-                       continue;
+                       break;
                }
-               break;
        }
 
        /* read symbol name, doing renaming if necessary */



Home | Main Index | Thread Index | Old Index