Re: [PATCH -mm] -funsigned-char, x86: make struct p4_event_bind::cntr signed array

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

 



On Thu, Oct 20, 2022 at 10:59 PM Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
>
> It is very entertaining, i've given up and started patching sparse
> but it needs more because char constants are ints:

I think you can fix that by simply warning about character constants
with the high bit set.

Something like this..

              Linus
 char.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/char.c b/char.c
index 730ae3f5..3706e033 100644
--- a/char.c
+++ b/char.c
@@ -93,6 +93,10 @@ void get_char_constant(struct token *token, unsigned long long *val)
 	if (p != end)
 		warning(token->pos,
 			"multi-character character constant");
+	if (v & 0x80) {
+		if (type >= TOKEN_CHAR && type <= TOKEN_CHAR_EMBEDDED_3)
+			warning(token->pos, "character constant with sign bit set");
+	}
 	*val = v;
 }
 

[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux