From 280d52b7d78ad2ba695f5f6faa61f0679c447f3c Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 10 Sep 2014 01:09:43 +1000 Subject: Silence compiler warnings about array subscripts of type 'char' Cygwin GCC complains about code like isprint(c), where c is of type char. The isX() and toX() functions/macros (ISO C allows either) all accept an int, whose value should be either that of an unsigned char, or the special value EOF (== -1). So cast to unsigned char each argument to isprint, tolower, etc. Silences several warnings of the form: gpsutils.c: In function 'safe_atof': gpsutils.c:90:5: warning: array subscript has type 'char' [-Wchar-subscripts] while (isspace(*p)) { ^ gpsutils.c:188:2: warning: array subscript has type 'char' [-Wchar-subscripts] while (isdigit(*p)) { ^ --- hex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hex.c') diff --git a/hex.c b/hex.c index ac1705f3..635bd53a 100644 --- a/hex.c +++ b/hex.c @@ -17,7 +17,7 @@ const char /*@ observer @*/ *gpsd_packetdump(char *scbuf, size_t scbuflen, assert(binbuf != NULL); for (cp = binbuf; cp < binbuf + binbuflen; cp++) - if (!isprint(*cp) && !isspace(*cp)) + if (!isprint((unsigned char) *cp) && !isspace((unsigned char) *cp)) printable = false; if (printable) return binbuf; -- cgit v1.2.1