From be2c418b73fcb6c606725d84c18b0ad618082c75 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Tue, 25 Aug 2009 14:11:44 -0700 Subject: [PATCH] Cleanup isdigit() warnings. NetBSD's gcc complains if isdigit()'s argument is an unadorned char. This provides an appropriate cast. --- CodingStyle | 4 +++- SubmittingPatches | 2 +- extras/ezio/ovs-switchui.c | 9 ++++++--- lib/dpif-linux.c | 3 ++- lib/dpif-netdev.c | 2 +- lib/unixctl.c | 4 +++- lib/vlog.c | 2 +- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CodingStyle b/CodingStyle index 69df907a..f4765ad8 100644 --- a/CodingStyle +++ b/CodingStyle @@ -430,7 +430,9 @@ and precedence makes it necessary, or unless the operands are themselves expressions that use && and ||. Thus: - if (!isdigit(s[0]) || !isdigit(s[1]) || !isdigit(s[2])) { + if (!isdigit((unsigned char)s[0]) + || !isdigit((unsigned char)s[1]) + || !isdigit((unsigned char)s[2])) { printf("string %s does not start with 3-digit code\n", s); } diff --git a/SubmittingPatches b/SubmittingPatches index 50398f89..917cddbf 100644 --- a/SubmittingPatches +++ b/SubmittingPatches @@ -180,7 +180,7 @@ index 32647ea..00cffbc 100644 - svec_init(&new_br); - for (i = 0; i < raw_new_br.n; i++) { - const char *name = raw_new_br.names[i]; -- if (!strncmp(name, "dp", 2) && isdigit(name[2])) { +- if (!strncmp(name, "dp", 2) && isdigit((unsigned char)name[2])) { - VLOG_ERR("%s is not a valid bridge name (bridges may not be " - "named \"dp\" followed by a digit)", name); - } else { diff --git a/extras/ezio/ovs-switchui.c b/extras/ezio/ovs-switchui.c index ad006fae..721717ee 100644 --- a/extras/ezio/ovs-switchui.c +++ b/extras/ezio/ovs-switchui.c @@ -2801,7 +2801,8 @@ cmd_configure(const struct dict *dict UNUSED) out = prompt("Ctlr rate limit:", in, "^(Disabled|("NUM100_TO_99999_RE")/s)$"); free(in); - config.rate_limit = isdigit(out[0]) ? atoi(out) : -1; + config.rate_limit + = isdigit((unsigned char)out[0]) ? atoi(out) : -1; free(out); break; @@ -2812,7 +2813,8 @@ cmd_configure(const struct dict *dict UNUSED) out = prompt("Activity probe:", in, "^(Default|("NUM5_TO_99999_RE") s)$"); free(in); - config.inactivity_probe = isdigit(out[0]) ? atoi(out) : -1; + config.inactivity_probe + = isdigit((unsigned char)out[0]) ? atoi(out) : -1; free(out); break; @@ -2823,7 +2825,8 @@ cmd_configure(const struct dict *dict UNUSED) out = prompt("Max backoff:", in, "^(Default|("NUM1_TO_99999_RE") s)$"); free(in); - config.max_backoff = isdigit(out[0]) ? atoi(out) : -1; + config.max_backoff + = isdigit((unsigned char)out[0]) ? atoi(out) : -1; free(out); break; } diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index 4d8c8048..a1a666bd 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -104,7 +104,8 @@ dpif_linux_open(const char *name UNUSED, char *suffix, bool create, { int minor; - minor = !strncmp(name, "dp", 2) && isdigit(name[2]) ? atoi(name + 2) : -1; + minor = !strncmp(name, "dp", 2) + && isdigit((unsigned char)name[2]) ? atoi(name + 2) : -1; if (create) { if (minor >= 0) { return create_minor(suffix, minor, dpifp); diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 4ff1a425..d8f5ba73 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -160,7 +160,7 @@ get_dp_netdev(const struct dpif *dpif) static int name_to_dp_idx(const char *name) { - if (!strncmp(name, "dp", 2) && isdigit(name[2])) { + if (!strncmp(name, "dp", 2) && isdigit((unsigned char)name[2])) { int dp_idx = atoi(name + 2); if (dp_idx >= 0 && dp_idx < N_DP_NETDEVS) { return dp_idx; diff --git a/lib/unixctl.c b/lib/unixctl.c index 17bd6cb5..7d6fdd67 100644 --- a/lib/unixctl.c +++ b/lib/unixctl.c @@ -553,7 +553,9 @@ unixctl_client_transact(struct unixctl_client *client, s = ds_cstr(&line); if (*reply_code == -1) { - if (!isdigit(s[0]) || !isdigit(s[1]) || !isdigit(s[2])) { + if (!isdigit((unsigned char)s[0]) + || !isdigit((unsigned char)s[1]) + || !isdigit((unsigned char)s[2])) { VLOG_WARN("reply from %s does not start with 3-digit code", client->connect_path); error = EPROTO; diff --git a/lib/vlog.c b/lib/vlog.c index 1b95d96c..5496f010 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -522,7 +522,7 @@ format_log_message(enum vlog_module module, enum vlog_level level, p++; } field = 0; - while (isdigit(*p)) { + while (isdigit((unsigned char)*p)) { field = (field * 10) + (*p - '0'); p++; } -- 2.30.2