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 /gpsutils.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 'gpsutils.c')
-rw-r--r-- | gpsutils.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -87,7 +87,7 @@ double safe_atof(const char *string) */ p = string; - while (isspace(*p)) { + while (isspace((unsigned char) *p)) { p += 1; } if (*p == '-') { @@ -185,7 +185,7 @@ double safe_atof(const char *string) } expSign = false; } - while (isdigit(*p)) { + while (isdigit((unsigned char) *p)) { exp = exp * 10 + (*p - '0'); p += 1; } |