Cleanup isdigit() warnings.
authorJustin Pettit <jpettit@nicira.com>
Tue, 25 Aug 2009 21:11:44 +0000 (14:11 -0700)
committerJustin Pettit <jpettit@nicira.com>
Tue, 25 Aug 2009 21:11:44 +0000 (14:11 -0700)
NetBSD's gcc complains if isdigit()'s argument is an unadorned char.  This
provides an appropriate cast.

CodingStyle
SubmittingPatches
extras/ezio/ovs-switchui.c
lib/dpif-linux.c
lib/dpif-netdev.c
lib/unixctl.c
lib/vlog.c

index 69df907..f4765ad 100644 (file)
@@ -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);
     }
 
index 50398f8..917cddb 100644 (file)
@@ -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 {
index ad006fa..721717e 100644 (file)
@@ -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;
         }
index 4d8c804..a1a666b 100644 (file)
@@ -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);
index 4ff1a42..d8f5ba7 100644 (file)
@@ -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;
index 17bd6cb..7d6fdd6 100644 (file)
@@ -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;
index 1b95d96..5496f01 100644 (file)
@@ -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++;
         }