Module Name:    src
Committed By:   rillig
Date:           Sun Aug 22 22:09:57 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_338.c msg_338.exp

Log Message:
tests/lint: demonstrate wrong warning for '?' in getopt


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_338.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_338.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_338.c
diff -u src/tests/usr.bin/xlint/lint1/msg_338.c:1.3 src/tests/usr.bin/xlint/lint1/msg_338.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_338.c:1.3	Mon Apr  5 01:35:34 2021
+++ src/tests/usr.bin/xlint/lint1/msg_338.c	Sun Aug 22 22:09:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_338.c,v 1.3 2021/04/05 01:35:34 rillig Exp $	*/
+/*	$NetBSD: msg_338.c,v 1.4 2021/08/22 22:09:57 rillig Exp $	*/
 # 3 "msg_338.c"
 
 // Test for message: option '%c' should be handled in the switch [338]
@@ -51,3 +51,28 @@ main(int argc, char **argv)
 
 	return 0;
 }
+
+void usage(void);
+
+/* Seen in usr.bin/ftp/main.c 1.127 from 2020-07-18. */
+int
+question_option(int argc, char **argv)
+{
+	int c;
+
+	/* FIXME */
+	/* expect+1: warning: option '?' should be handled in the switch [338] */
+	while ((c = getopt(argc, argv, "?x")) != -1) {
+		switch (c) {
+		case 'x':
+			break;
+		case '?':
+			usage();
+			return 0;
+		default:
+			usage();
+			return 1;
+		}
+	}
+	return 0;
+}

Index: src/tests/usr.bin/xlint/lint1/msg_338.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_338.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_338.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_338.exp:1.1	Fri Feb 19 12:28:56 2021
+++ src/tests/usr.bin/xlint/lint1/msg_338.exp	Sun Aug 22 22:09:57 2021
@@ -2,3 +2,4 @@ msg_338.c(26): warning: option 'e' shoul
 msg_338.c(28): warning: option 'f' should be listed in the options string [339]
 msg_338.c(14): warning: option 'c' should be handled in the switch [338]
 msg_338.c(14): warning: option 'd' should be handled in the switch [338]
+msg_338.c(65): warning: option '?' should be handled in the switch [338]

Reply via email to