lkml.org 
[lkml]   [2022]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [PATCH -mm] -funsigned-char, x86: make struct p4_event_bind::cntr signed array
On Thu, Oct 20, 2022 at 10:59 PM Alexey Dobriyan <adobriyan@gmail.com> 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;
}
\
 
 \ /
  Last update: 2022-10-21 19:13    [W:0.161 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site