On 14.10.2013 15:02, Dan Carpenter wrote: > On Fri, Oct 11, 2013 at 02:04:07PM +0200, Peter Oberparleiter wrote: >> Running smatch on s390x incorrectly reports impossible conditions when >> comparing variables of type 'char' with constant values larger than 127, >> even though 'char' is implemented on s390x as unsigned type. >> >> A solution to this problem might be to use the __CHAR__UNSIGNED__ macro [1] >> to determine the correct signedness of the 'char' type at compile time. > > Smatch used to try figure out type information manually but these days > it hopefully should be using the information from Sparse. I'm not sure > if all the crud has been totally deleted. Does this patch work? Sorry, my bad - the macro is actually spelled __CHAR_UNSIGNED__ (no double underscore in the middle). Using the corrected macro name, the patch fixes the problem (tested on latest git). Thanks! > > diff --git a/symbol.c b/symbol.c > index 0427a23..6ec25c2 100644 > --- a/symbol.c > +++ b/symbol.c > @@ -789,6 +789,12 @@ void init_symbols(void) > } > } > > +#ifdef __CHAR__UNSIGNED__ > +#define CHAR_SIGNEDNESS MOD_UNSIGNED > +#else > +#define CHAR_SIGNEDNESS MOD_SIGNED > +#endif > + > #define MOD_ESIGNED (MOD_SIGNED | MOD_EXPLICITLY_SIGNED) > #define MOD_LL (MOD_LONG | MOD_LONGLONG) > #define MOD_LLL MOD_LONGLONGLONG > @@ -806,7 +812,7 @@ static const struct ctype_declare { > { &incomplete_ctype,SYM_BASETYPE, 0, NULL, NULL, NULL }, > { &bad_ctype, SYM_BASETYPE, 0, NULL, NULL, NULL }, > > - { &char_ctype, SYM_BASETYPE, MOD_SIGNED | MOD_CHAR, &bits_in_char, &max_int_alignment, &int_type }, > + { &char_ctype, SYM_BASETYPE, CHAR_SIGNEDNESS | MOD_CHAR, &bits_in_char, &max_int_alignment, &int_type }, > { &schar_ctype, SYM_BASETYPE, MOD_ESIGNED | MOD_CHAR, &bits_in_char, &max_int_alignment, &int_type }, > { &uchar_ctype, SYM_BASETYPE, MOD_UNSIGNED | MOD_CHAR, &bits_in_char, &max_int_alignment, &int_type }, > { &short_ctype, SYM_BASETYPE, MOD_SIGNED | MOD_SHORT, &bits_in_short, &max_int_alignment, &int_type }, > -- Peter Oberparleiter Linux on System z Development - IBM Germany -- To unsubscribe from this list: send the line "unsubscribe smatch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html