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: fix wrong warning about '?' in getopt
details: https://anonhg.NetBSD.org/src/rev/7ddf58e4090c
branches: trunk
changeset: 985407:7ddf58e4090c
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 22 22:15:07 2021 +0000
description:
lint: fix wrong warning about '?' in getopt
diffstat:
tests/usr.bin/xlint/lint1/msg_338.c | 11 +++++++----
tests/usr.bin/xlint/lint1/msg_338.exp | 1 -
usr.bin/xlint/lint1/ckgetopt.c | 9 +++------
3 files changed, 10 insertions(+), 11 deletions(-)
diffs (71 lines):
diff -r 2b9796dfcedc -r 7ddf58e4090c tests/usr.bin/xlint/lint1/msg_338.c
--- a/tests/usr.bin/xlint/lint1/msg_338.c Sun Aug 22 22:09:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_338.c Sun Aug 22 22:15:07 2021 +0000
@@ -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 @@
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':
diff -r 2b9796dfcedc -r 7ddf58e4090c tests/usr.bin/xlint/lint1/msg_338.exp
--- a/tests/usr.bin/xlint/lint1/msg_338.exp Sun Aug 22 22:09:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_338.exp Sun Aug 22 22:15:07 2021 +0000
@@ -2,4 +2,3 @@
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]
diff -r 2b9796dfcedc -r 7ddf58e4090c usr.bin/xlint/lint1/ckgetopt.c
--- a/usr.bin/xlint/lint1/ckgetopt.c Sun Aug 22 22:09:57 2021 +0000
+++ b/usr.bin/xlint/lint1/ckgetopt.c Sun Aug 22 22:15:07 2021 +0000
@@ -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 @@
{
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;
Home |
Main Index |
Thread Index |
Old Index