mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robert Schwebel <r.schwebel@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] readline: keys should be unsigned char consistently
Date: Fri, 18 Dec 2009 01:23:53 +0100	[thread overview]
Message-ID: <20091218002353.GP22533@pengutronix.de> (raw)

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 <r.schwebel@pengutronix.de>
---
 commands/edit.c   |    2 +-
 include/readkey.h |   12 ++++++------
 lib/readkey.c     |    4 ++--
 lib/readline.c    |   10 +++++-----
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/commands/edit.c b/commands/edit.c
index 6503edf..4f4ba4f 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -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;
diff --git a/include/readkey.h b/include/readkey.h
index d27f0b4..1f149b5 100644
--- a/include/readkey.h
+++ b/include/readkey.h
@@ -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 */
 
diff --git a/lib/readkey.c b/lib/readkey.c
index 5937fd0..3efe5c4 100644
--- a/lib/readkey.c
+++ b/lib/readkey.c
@@ -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];
diff --git a/lib/readline.c b/lib/readline.c
index 750da3b..73cf046 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -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;
 		}
-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2009-12-18  0:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091218002353.GP22533@pengutronix.de \
    --to=r.schwebel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox