Module Name: src
Committed By: rillig
Date: Wed Dec 18 18:14:54 UTC 2024
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_341.c
src/usr.bin/xlint/lint1: ckctype.c
Log Message:
lint: warn about unusual argument types in <ctype.h> functions
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_341.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/xlint/lint1/ckctype.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_341.c
diff -u src/tests/usr.bin/xlint/lint1/msg_341.c:1.3 src/tests/usr.bin/xlint/lint1/msg_341.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_341.c:1.3 Tue Mar 28 14:44:35 2023
+++ src/tests/usr.bin/xlint/lint1/msg_341.c Wed Dec 18 18:14:54 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_341.c,v 1.3 2023/03/28 14:44:35 rillig Exp $ */
+/* $NetBSD: msg_341.c,v 1.4 2024/12/18 18:14:54 rillig Exp $ */
# 3 "msg_341.c"
// Test for message: argument to '%s' must be 'unsigned char' or EOF, not '%s' [341]
@@ -62,7 +62,7 @@ function_call_int(int c)
}
void
-macro_invocation_NetBSD(char c)
+macro_invocation_NetBSD(char c, signed char sc)
{
/* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' [341] */
@@ -76,4 +76,11 @@ macro_invocation_NetBSD(char c)
/* expect+1: warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' [342] */
sink(((int)((_ctype_tab_ + 1)[((unsigned int)c)] & 0x0040)));
+
+ // https://mail-index.netbsd.org/current-users/2024/12/15/msg045888.html
+ /* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'unsigned int' [341] */
+ sink(((int)((_ctype_tab_ + 1)[(0xffffffffu)])));
+
+ /* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'signed char' [341] */
+ sink(((int)((_ctype_tab_ + 1)[sc])));
}
Index: src/usr.bin/xlint/lint1/ckctype.c
diff -u src/usr.bin/xlint/lint1/ckctype.c:1.12 src/usr.bin/xlint/lint1/ckctype.c:1.13
--- src/usr.bin/xlint/lint1/ckctype.c:1.12 Tue Mar 19 23:19:03 2024
+++ src/usr.bin/xlint/lint1/ckctype.c Wed Dec 18 18:14:54 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ckctype.c,v 1.12 2024/03/19 23:19:03 rillig Exp $ */
+/* $NetBSD: ckctype.c,v 1.13 2024/12/18 18:14:54 rillig Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: ckctype.c,v 1.12 2024/03/19 23:19:03 rillig Exp $");
+__RCSID("$NetBSD: ckctype.c,v 1.13 2024/12/18 18:14:54 rillig Exp $");
#endif
#include <string.h>
@@ -112,7 +112,7 @@ check_ctype_arg(const char *func, const
}
cn = before_conversion(arg);
- if (cn->tn_type->t_tspec == CHAR) {
+ if (cn->tn_type->t_tspec != UCHAR && cn->tn_type->t_tspec != INT) {
/* argument to '%s' must be 'unsigned char' or EOF, not '%s' */
warning(341, func, type_name(cn->tn_type));
return;