Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: test passing sizeof(in...



details:   https://anonhg.NetBSD.org/src/rev/6dc9bbf6de12
branches:  trunk
changeset: 985565:6dc9bbf6de12
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Aug 30 18:33:37 2021 +0000

description:
tests/lint: test passing sizeof(int) to parameter type 'unsigned int'

Seen in usr.sbin/inetd/inetd.c, which calls getnameinfo and passes
sizeof(buf).

diffstat:

 tests/usr.bin/xlint/lint1/msg_259.c   |  14 +++++++++++++-
 tests/usr.bin/xlint/lint1/msg_259.exp |   1 +
 2 files changed, 14 insertions(+), 1 deletions(-)

diffs (33 lines):

diff -r 2b46618b2d98 -r 6dc9bbf6de12 tests/usr.bin/xlint/lint1/msg_259.c
--- a/tests/usr.bin/xlint/lint1/msg_259.c       Mon Aug 30 18:21:11 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_259.c       Mon Aug 30 18:33:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_259.c,v 1.12 2021/08/21 11:58:12 rillig Exp $      */
+/*     $NetBSD: msg_259.c,v 1.13 2021/08/30 18:33:37 rillig Exp $      */
 # 3 "msg_259.c"
 
 // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259]
@@ -68,3 +68,15 @@
        /* expect+1: warning: argument #1 is converted from 'long' to 'unsigned long long' due to prototype [259] */
        farg_unsigned_long_long(l);
 }
+
+void
+pass_sizeof_as_smaller_type(void)
+{
+       /*
+        * XXX: Even though the expression has type size_t, it has a constant
+        * value that fits effortless into an 'unsigned int', it's so small
+        * that it would even fit into a 3-bit bit-field.
+        */
+       /* expect+1: warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259] */
+       farg_unsigned_int(sizeof(int));
+}
diff -r 2b46618b2d98 -r 6dc9bbf6de12 tests/usr.bin/xlint/lint1/msg_259.exp
--- a/tests/usr.bin/xlint/lint1/msg_259.exp     Mon Aug 30 18:21:11 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_259.exp     Mon Aug 30 18:33:37 2021 +0000
@@ -3,3 +3,4 @@
 msg_259.c(50): warning: argument #1 is converted from 'long' to 'unsigned long' due to prototype [259]
 msg_259.c(54): warning: argument #1 is converted from 'long long' to 'unsigned long long' due to prototype [259]
 msg_259.c(69): warning: argument #1 is converted from 'long' to 'unsigned long long' due to prototype [259]
+msg_259.c(81): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259]



Home | Main Index | Thread Index | Old Index