Some archichectures, like ARM or PPC, use unsigned for plain chars while others, like the Intel's, use signed ones. Sparse understand -funsigned-char but by default uses the native signedness. Fix this by setting the proper signedness of plain chars for the archs that Sparse know about. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- lib.c | 2 +- machine.h | 6 ------ target.c | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib.c b/lib.c index fbf14282b..8bd1d1f98 100644 --- a/lib.c +++ b/lib.c @@ -312,7 +312,7 @@ unsigned long long fmemcpy_max_count = 100000; unsigned long fpasses = ~0UL; int fpic = 0; int fpie = 0; -int funsigned_char = UNSIGNED_CHAR; +int funsigned_char = -1; int preprocess_only; diff --git a/machine.h b/machine.h index e24822a7f..22b05d91a 100644 --- a/machine.h +++ b/machine.h @@ -70,10 +70,4 @@ enum machine { #define MACH_NATIVE MACH_UNKNOWN #endif -#if defined(__CHAR_UNSIGNED__) -#define UNSIGNED_CHAR 1 -#else -#define UNSIGNED_CHAR 0 -#endif - #endif diff --git a/target.c b/target.c index 90097818f..497ecdc5e 100644 --- a/target.c +++ b/target.c @@ -137,6 +137,24 @@ void init_target(void) break; } + switch (arch_mach) { + case MACH_ARM: + case MACH_ARM64: + case MACH_PPC32: + case MACH_PPC64: + case MACH_RISCV32: + case MACH_RISCV64: + case MACH_S390: + case MACH_S390X: + if (funsigned_char == -1) + funsigned_char = 1; + break; + default: + if (funsigned_char == -1) + funsigned_char = 0; + break; + } + switch (arch_m64) { case ARCH_X32: max_int_alignment = 8; -- 2.24.0