Module Name:    src
Committed By:   rillig
Date:           Mon Aug 30 18:33:37 UTC 2021

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

Log Message:
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).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/xlint/lint1/msg_259.c
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_259.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_259.c
diff -u src/tests/usr.bin/xlint/lint1/msg_259.c:1.12 src/tests/usr.bin/xlint/lint1/msg_259.c:1.13
--- src/tests/usr.bin/xlint/lint1/msg_259.c:1.12	Sat Aug 21 11:58:12 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259.c	Mon Aug 30 18:33:37 2021
@@ -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 @@ convert_to_corresponding_unsigned(int i,
 	/* 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));
+}

Index: src/tests/usr.bin/xlint/lint1/msg_259.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_259.exp:1.9 src/tests/usr.bin/xlint/lint1/msg_259.exp:1.10
--- src/tests/usr.bin/xlint/lint1/msg_259.exp:1.9	Sat Aug 21 11:58:12 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259.exp	Mon Aug 30 18:33:37 2021
@@ -3,3 +3,4 @@ msg_259.c(46): warning: argument #1 is c
 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]

Reply via email to