readline: keys should be unsigned char consistently
PATCH 1/1 readline: keys should be unsigned char consistently
When building the sandbox, I get these warnings:
lib/readline.c: In function 'readline':lib/readline.c:264: warning: case label value is less than minimum value for type lib/readline.c:274: warning: case label value is less than minimum value for type lib/readline.c:290: warning: case label value is less than minimum value for type
Make keys unsigned char consistently.
Signed-off-by Robert Schwebel <[email protected]>
--- commands/edit.c | 2 +- include/readkey.h | 12 ++++++------ lib/readkey.c | 4 ++-- lib/readline.c | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-)
commands/edit.c +1 -1
@@ -394,7 +394,7 @@ static int do_edit(cmd_tbl_t * cmdtp, int argc, char *argv[])int lastscrcol;int i;int linepos; -char c; +unsigned char c;if (argc !=2 )return COMMAND_ERROR_USAGE ;
include/readkey.h +6 -6
@@ -14,15 +14,15 @@#define KEY_ERASE_LINE CTL_CH('x')#define KEY_INSERT CTL_CH('o')#define KEY_CLEAR_SCREEN CTL_CH('l') -#define KEY_DEL7 (char)127 -#define KEY_END (char)133 // Cursor Key End -#define KEY_PAGEUP (char)135 // Cursor Key Page Up -#define KEY_PAGEDOWN (char)136 // Cursor Key Page Down -#define KEY_DEL (char)137 // Cursor Key Del +#define KEY_DEL7 (unsigned char)127 +#define KEY_END (unsigned char)133 // Cursor Key End +#define KEY_PAGEUP (unsigned char)135 // Cursor Key Page Up +#define KEY_PAGEDOWN (unsigned char)136 // Cursor Key Page Down +#define KEY_DEL (unsigned char)137 // Cursor Key Del#define ANSI_CLEAR_SCREEN "\e[2J\e[;H" -char read_key (void ); +unsigned char read_key (void );#endif /* READKEY_H */
lib/readkey.c +2 -2
@@ -28,7 +28,7 @@struct esc_cmds {const char *seq; -char val; +unsigned char val; };static const struct esc_cmds esccmds[] = {
@@ -52,7 +52,7 @@ static const struct esc_cmds esccmds[] = { {"[6~", KEY_PAGEDOWN},// Cursor Key Page Down }; -char read_key (void ) +unsigned char read_key (void ) {char c;char esc[5 ];
lib/readline.c +5 -5
@@ -17,8 +17,8 @@#define MAX_CMDBUF_SIZE 256#define CTL_BACKSPACE ('\b') -#define DEL ((char)255) -#define DEL7 ((char)127) +#define DEL ((unsigned char)255) +#define DEL7 ((unsigned char)127)#define CREAD_HIST_CHAR ('!')#define getcmd_putch (ch) putchar(ch)
@@ -137,8 +137,8 @@ static char* hist_next(void) } \ } -static void cread_add_char (char ichar,int insert,unsigned long *num, -unsigned long *eol_num,char *buf,unsigned long len) +static void cread_add_char (unsigned char ichar,int insert,unsigned long *num, +unsigned long *eol_num,unsigned char *buf,unsigned long len) {unsigned long wlen;
@@ -328,7 +328,7 @@ int readline(const char *prompt, char *buf, int len)continue ; }default : -if (isascii (ichar) &&isprint (ichar)) +if (isascii ((int )ichar) &&isprint ((int )ichar))cread_add_char (ichar, insert, &num, &eol_num, buf, len);break ; }
Signature · 12 lines
1.5.6.5 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox