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 /packet.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 'packet.c')
-rw-r--r-- | packet.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1500,7 +1500,7 @@ void packet_parse(struct gps_lexer_t *lexer) * Back up past any whitespace. Need to do this because * at least one GPS (the Firefly 1a) emits \r\r\n */ - for (end = (char *)lexer->inbufptr - 1; isspace(*end); end--) + for (end = (char *)lexer->inbufptr - 1; isspace((unsigned char) *end); end--) continue; while (strchr("0123456789ABCDEF", *end)) --end; @@ -1509,8 +1509,8 @@ void packet_parse(struct gps_lexer_t *lexer) for (n = 1; (char *)lexer->inbuffer + n < end; n++) crc ^= lexer->inbuffer[n]; (void)snprintf(csum, sizeof(csum), "%02X", crc); - checksum_ok = (csum[0] == toupper(end[1]) - && csum[1] == toupper(end[2])); + checksum_ok = (csum[0] == toupper((unsigned char) end[1]) + && csum[1] == toupper((unsigned char) end[2])); } if (!checksum_ok) { gpsd_report(&lexer->errout, LOG_WARN, |