Module Name: src
Committed By: rillig
Date: Sun Aug 22 22:15:07 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_338.c msg_338.exp
src/usr.bin/xlint/lint1: ckgetopt.c
Log Message:
lint: fix wrong warning about '?' in getopt
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_338.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_338.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/lint1/ckgetopt.c
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.4 src/tests/usr.bin/xlint/lint1/msg_338.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_338.c:1.4 Sun Aug 22 22:09:57 2021
+++ src/tests/usr.bin/xlint/lint1/msg_338.c Sun Aug 22 22:15:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_338.c,v 1.4 2021/08/22 22:09:57 rillig Exp $ */
+/* $NetBSD: msg_338.c,v 1.5 2021/08/22 22:15:07 rillig Exp $ */
# 3 "msg_338.c"
// Test for message: option '%c' should be handled in the switch [338]
@@ -54,14 +54,17 @@ main(int argc, char **argv)
void usage(void);
-/* Seen in usr.bin/ftp/main.c 1.127 from 2020-07-18. */
+/*
+ * Before ckgetopt.c 1.11 from 2021-08-23, lint wrongly warned about a
+ * missing '?' in the switch statement, even though it was there.
+ *
+ * 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':
Index: src/tests/usr.bin/xlint/lint1/msg_338.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_338.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_338.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_338.exp:1.2 Sun Aug 22 22:09:57 2021
+++ src/tests/usr.bin/xlint/lint1/msg_338.exp Sun Aug 22 22:15:07 2021
@@ -2,4 +2,3 @@ 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]
Index: src/usr.bin/xlint/lint1/ckgetopt.c
diff -u src/usr.bin/xlint/lint1/ckgetopt.c:1.10 src/usr.bin/xlint/lint1/ckgetopt.c:1.11
--- src/usr.bin/xlint/lint1/ckgetopt.c:1.10 Fri Jun 4 21:12:10 2021
+++ src/usr.bin/xlint/lint1/ckgetopt.c Sun Aug 22 22:15:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ckgetopt.c,v 1.10 2021/06/04 21:12:10 rillig Exp $ */
+/* $NetBSD: ckgetopt.c,v 1.11 2021/08/22 22:15:07 rillig Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: ckgetopt.c,v 1.10 2021/06/04 21:12:10 rillig Exp $");
+__RCSID("$NetBSD: ckgetopt.c,v 1.11 2021/08/22 22:15:07 rillig Exp $");
#endif
#include <stdbool.h>
@@ -113,13 +113,10 @@ check_unlisted_option(char opt)
{
lint_assert(ck.options != NULL);
- if (opt == '?')
- return;
-
char *optptr = strchr(ck.options, opt);
if (optptr != NULL)
*optptr = ' ';
- else {
+ else if (opt != '?') {
/* option '%c' should be listed in the options string */
warning(339, opt);
return;