diff options
author | Matt <ukyg9e5r6k7gubiekd6@yahoo.com> | 2014-09-10 01:09:43 +1000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2014-09-10 09:10:02 -0400 |
commit | 280d52b7d78ad2ba695f5f6faa61f0679c447f3c (patch) | |
tree | 1159db868a8f914f9b5567473a6059f04f2fe974 /hex.c | |
parent | 60583e9ee10b778934452845f004b94ce5c74205 (diff) | |
download | gpsd-280d52b7d78ad2ba695f5f6faa61f0679c447f3c.tar.gz |
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)) {
^
Diffstat (limited to 'hex.c')
-rw-r--r-- | hex.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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; |