From 8e4202ced136f4d997a500061d3089bffa30c4ac Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 8 Feb 2021 13:27:56 +0100 Subject: [PATCH] software/bios/readline: Fix warnings if char is signed When building with --cpu-type=mor1kx: litex/soc/software/bios/readline.c: In function 'readline': litex/soc/software/bios/readline.c:271:3: warning: case label value exceeds maximum value for type [-Wswitch-outside-range] 271 | case KEY_END: | ^~~~ litex/soc/software/bios/readline.c:297:3: warning: case label value exceeds maximum value for type [-Wswitch-outside-range] 297 | case KEY_DEL: | ^~~~ litex/soc/software/bios/readline.c:281:3: warning: case label value exceeds maximum value for type [-Wswitch-outside-range] 281 | case DEL: | ^~~~ The C standard does not specify the signedness of "char", hence this depends on the implementation. On e.g. RISC-V, "char" is unsigned, but on OpenRISC, it is signed. Fix this by making the "ichar" variable explicitly unsigned. Signed-off-by: Geert Uytterhoeven --- litex/soc/software/bios/readline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litex/soc/software/bios/readline.c b/litex/soc/software/bios/readline.c index f507f1a65..a255ebfaa 100644 --- a/litex/soc/software/bios/readline.c +++ b/litex/soc/software/bios/readline.c @@ -190,7 +190,7 @@ int readline(char *buf, int len) unsigned int eol_num = 0; unsigned int wlen; int insert = 1; - char ichar; + unsigned char ichar; #ifndef TERM_NO_COMPLETE char tmp;