Module Name:    src
Committed By:   rillig
Date:           Fri Aug 27 17:49:32 UTC 2021

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

Log Message:
tests/lint: test wrong warning for bitwise '>>'

Seen in /usr/include/netbt/hci.h, function hci_filter_set.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_117.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_117.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_117.c
diff -u src/tests/usr.bin/xlint/lint1/msg_117.c:1.7 src/tests/usr.bin/xlint/lint1/msg_117.c:1.8
--- src/tests/usr.bin/xlint/lint1/msg_117.c:1.7	Sun Aug 15 13:08:20 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.c	Fri Aug 27 17:49:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_117.c,v 1.7 2021/08/15 13:08:20 rillig Exp $	*/
+/*	$NetBSD: msg_117.c,v 1.8 2021/08/27 17:49:31 rillig Exp $	*/
 # 3 "msg_117.c"
 
 // Test for message: bitwise '%s' on signed value possibly nonportable [117]
@@ -45,3 +45,17 @@ shr_unsigned_char(unsigned char uc)
 	 */
 	return uc >> 4;
 }
+
+unsigned char
+shr_unsigned_char_promoted(unsigned char bit)
+{
+	/*
+	 * Before TODO from TODO, lint wrongly warned that the bitwise shift
+	 * might be on a signed value, which was wrong.  Even though the
+	 * expression has type 'int', the value of the expression cannot be
+	 * negative, as long as int is larger than char, which holds for all
+	 * platforms supported by lint.
+	 */
+	/* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
+	return (unsigned char)((bit - 1) >> 5);
+}

Index: src/tests/usr.bin/xlint/lint1/msg_117.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_117.exp:1.6 src/tests/usr.bin/xlint/lint1/msg_117.exp:1.7
--- src/tests/usr.bin/xlint/lint1/msg_117.exp:1.6	Sun Aug 15 13:08:20 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.exp	Fri Aug 27 17:49:31 2021
@@ -4,3 +4,4 @@ msg_117.c(29): warning: bitwise '>>' on 
 msg_117.c(29): warning: shift amount 4660 is greater than bit-size 32 of 'int' [122]
 msg_117.c(35): warning: bitwise '>>' on signed value possibly nonportable [117]
 msg_117.c(35): warning: negative shift [121]
+msg_117.c(60): warning: bitwise '>>' on signed value possibly nonportable [117]

Reply via email to