Module Name:    src
Committed By:   rillig
Date:           Mon Aug 30 20:20:20 UTC 2021

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

Log Message:
lint: remove redundant call to strchr in decldef

This time, the branches for varargs, printflike and scanflike in the big
switch statement are covered by unit tests.  These tests would have
caught the previous "cleanup" that broke parsing of these function
attributes.  Furthermore, this second cleanup is closer to the original
code and conceptually simpler since it avoids having many 'continue'
statements in a 'switch' statement, which would have been unusual.

The branches for inline functions and used functions are still not
covered by the tests, but they are structurally equal to several other
branches.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint2/read.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/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.61 src/usr.bin/xlint/lint2/read.c:1.62
--- src/usr.bin/xlint/lint2/read.c:1.61	Mon Aug 30 19:07:57 2021
+++ src/usr.bin/xlint/lint2/read.c	Mon Aug 30 20:20:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.61 2021/08/30 19:07:57 rillig Exp $ */
+/* $NetBSD: read.c,v 1.62 2021/08/30 20:20:20 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.61 2021/08/30 19:07:57 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.62 2021/08/30 20:20:20 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -387,9 +387,8 @@ decldef(pos_t *posp, const char *cp)
 
 	used = false;
 
-	while (strchr("deiorstuvPS", (c = *cp)) != NULL) {
-		cp++;
-		switch (c) {
+	for (;;) {
+		switch (c = *cp++) {
 		case 'd':
 			if (sym.s_def != NODECL)
 				inperr("def");
@@ -448,9 +447,13 @@ decldef(pos_t *posp, const char *cp)
 			sym.s_scanflike = true;
 			sym.s_scanflike_arg = parse_short(&cp);
 			break;
+		default:
+			cp--;
+			goto done_function_attributes;
 		}
 	}
 
+done_function_attributes:
 	/* read symbol name, doing renaming if necessary */
 	name = inpname(cp, &cp);
 	renamed = false;

Reply via email to