[ovs-dev] [PATCH 10/18] some ctype related casts to suppress gcc warnings on NetBSD.
YAMAMOTO Takashi
yamamoto at valinux.co.jp
Thu Jan 31 10:49:44 UTC 2013
From: YAMAMOTO Takashi <yamt at mwd.biglobe.ne.jp>
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 <yamamoto at valinux.co.jp>
---
lib/json.c | 14 +++++++-------
lib/ofp-util.c | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/json.c b/lib/json.c
index 5c96851..29ef246 100644
--- a/lib/json.c
+++ b/lib/json.c
@@ -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;
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index c66cd40..2fd3c00 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -924,7 +924,7 @@ ofputil_version_from_string(const char *s)
}
static bool
-is_delimiter(char c)
+is_delimiter(unsigned char c)
{
return isspace(c) || c == ',';
}
--
1.7.12
More information about the dev
mailing list