some ctype related casts to suppress gcc warnings on NetBSD
authorYAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Mon, 22 Apr 2013 13:20:10 +0000 (22:20 +0900)
committerBen Pfaff <blp@nicira.com>
Mon, 22 Apr 2013 15:52:24 +0000 (08:52 -0700)
where it can't be EOF, cast a value to unsigned char before passing it
to ctype functions to avoid unintended sign extension.

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/json.c
lib/ofp-util.c

index 06a9a42..af385c6 100644 (file)
@@ -620,11 +620,11 @@ json_lex_number(struct json_parser *p)
     significand = 0;
     if (*cp == '0') {
         cp++;
-        if (isdigit(*cp)) {
+        if (isdigit((unsigned char) *cp)) {
             json_error(p, "leading zeros not allowed");
             return;
         }
-    } else if (isdigit(*cp)) {
+    } else if (isdigit((unsigned char) *cp)) {
         do {
             if (significand <= ULLONG_MAX / 10) {
                 significand = significand * 10 + (*cp - '0');
@@ -635,7 +635,7 @@ json_lex_number(struct json_parser *p)
                 }
             }
             cp++;
-        } while (isdigit(*cp));
+        } while (isdigit((unsigned char) *cp));
     } else {
         json_error(p, "'-' must be followed by digit");
         return;
@@ -644,7 +644,7 @@ json_lex_number(struct json_parser *p)
     /* Optional fraction. */
     if (*cp == '.') {
         cp++;
-        if (!isdigit(*cp)) {
+        if (!isdigit((unsigned char) *cp)) {
             json_error(p, "decimal point must be followed by digit");
             return;
         }
@@ -656,7 +656,7 @@ json_lex_number(struct json_parser *p)
                 imprecise = true;
             }
             cp++;
-        } while (isdigit(*cp));
+        } while (isdigit((unsigned char) *cp));
     }
 
     /* Optional exponent. */
@@ -672,7 +672,7 @@ json_lex_number(struct json_parser *p)
             cp++;
         }
 
-        if (!isdigit(*cp)) {
+        if (!isdigit((unsigned char) *cp)) {
             json_error(p, "exponent must contain at least one digit");
             return;
         }
@@ -685,7 +685,7 @@ json_lex_number(struct json_parser *p)
             }
             exponent = exponent * 10 + (*cp - '0');
             cp++;
-        } while (isdigit(*cp));
+        } while (isdigit((unsigned char) *cp));
 
         if (negative_exponent) {
             pow10 -= exponent;
index 6b78f84..42c3613 100644 (file)
@@ -922,7 +922,7 @@ ofputil_version_from_string(const char *s)
 }
 
 static bool
-is_delimiter(char c)
+is_delimiter(unsigned char c)
 {
     return isspace(c) || c == ',';
 }