From 17119ab0a52df5fb30749d038d796d7e78702e3c Mon Sep 17 00:00:00 2001 From: Serge Lamikhov-Center Date: Wed, 25 Dec 2013 15:26:03 +1100 Subject: Pass 'unsigned char' type to isdigit()/isspace()/isprint() functions The isdigit(), isprint(), etc. functions take an int, whose value is required to be in the range of an _unsigned_ char, or EOF. This, horribly, means that systems which have a signed char by default need casts to pass a char variable safely to these functions. We can't do this more nicely by making the variables themselves 'unsigned char *' because then we'll get warnings passing them to the strchr() etc. functions. At least the cygwin version of these functions, are designed to generate warnings if this isn't done, as explained by this comment from ctype.h: These macros are intentionally written in a manner that will trigger a gcc -Wall warning if the user mistakenly passes a 'char' instead of an int containing an 'unsigned char'. Signed-off-by: Serge Lamikhov-Center Signed-off-by: David Gibson --- util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util.c') diff --git a/util.c b/util.c index 2347af9..330b594 100644 --- a/util.c +++ b/util.c @@ -87,7 +87,7 @@ bool util_is_printable_string(const void *data, int len) while (s < se) { ss = s; - while (s < se && *s && isprint(*s)) + while (s < se && *s && isprint((unsigned char)*s)) s++; /* not zero, or not done yet */ -- cgit v1.1