]> git.proxmox.com Git - ovs.git/commitdiff
Fix format specifier technicalities.
authorBen Pfaff <blp@ovn.org>
Fri, 17 Mar 2017 20:38:55 +0000 (13:38 -0700)
committerBen Pfaff <blp@ovn.org>
Fri, 17 Mar 2017 20:39:01 +0000 (13:39 -0700)
Various printf() format specifiers in the tree had minor technical issues
which the Mac OS build reported, e.g. here:
https://s3.amazonaws.com/archive.travis-ci.org/jobs/208718342/log.txt

These tend to fall into two categories of harmless warnings:

1. Wrong width for types that are all promoted to 'int'.  For example,
both uint8_t and uint16_t are both promoted to 'int' as part of a call
to printf(), but using PRIu8 for a uint16_t causes a warning.

2. Wrong format specifier for type promoted to 'int' due to arithmetic.
For example, if 'x' is a uint8_t, then x >> 1 has type 'int' due to
C's promotion rules, so the correct format specifier is %d and using
PRIu8 will cause a warning.

This commit fixes the warnings.  I didn't see anything that rose to the
level of a bug.

These warnings only showed up on Mac OS X because of differences in the
format specifiers that Mac OS uses for PRI*.

Reported-by: Shu Shen <shu.shen@gmail.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
12 files changed:
lib/bfd.c
lib/match.c
lib/multipath.c
lib/odp-util.c
lib/ofp-actions.c
lib/ofp-print.c
lib/ofp-util.c
lib/ovs-router.c
ofproto/ofproto-dpif-xlate.c
tests/test-netflow.c
utilities/ovs-ofctl.c
vswitchd/bridge.c

index 87f3322ee461c1ff18ccc2b433ee32d7bc79094d..1fb1cfb2bc341b8e5ddcdc6ddf4f36f4130bed69 100644 (file)
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2014, 2015, 2016 Nicira, Inc.
+/* Copyright (c) 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1061,7 +1061,7 @@ log_msg(enum vlog_level level, const struct msg *p, const char *message,
 
     ds_put_format(&ds,
                   "%s: %s."
-                  "\n\tvers:%"PRIu8" diag:\"%s\" state:%s mult:%"PRIu8
+                  "\n\tvers:%d diag:\"%s\" state:%s mult:%"PRIu8
                   " length:%"PRIu8
                   "\n\tflags: %s"
                   "\n\tmy_disc:0x%"PRIx32" your_disc:0x%"PRIx32
index 4a8db187b72e79db4bf8964b628a1d4ed779101f..e50b134a8cc165c10671db57b7df16a4c9b94727 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1402,15 +1402,15 @@ match_format(const struct match *match, struct ds *s, int priority)
         format_eth_masked(s, "arp_tha", f->arp_tha, wc->masks.arp_tha);
     }
     if (wc->masks.nw_tos & IP_DSCP_MASK) {
-        ds_put_format(s, "%snw_tos=%s%"PRIu8",",
+        ds_put_format(s, "%snw_tos=%s%d,",
                       colors.param, colors.end, f->nw_tos & IP_DSCP_MASK);
     }
     if (wc->masks.nw_tos & IP_ECN_MASK) {
-        ds_put_format(s, "%snw_ecn=%s%"PRIu8",",
+        ds_put_format(s, "%snw_ecn=%s%d,",
                       colors.param, colors.end, f->nw_tos & IP_ECN_MASK);
     }
     if (wc->masks.nw_ttl) {
-        ds_put_format(s, "%snw_ttl=%s%"PRIu8",",
+        ds_put_format(s, "%snw_ttl=%s%d,",
                       colors.param, colors.end, f->nw_ttl);
     }
     if (wc->masks.mpls_lse[0] & htonl(MPLS_LABEL_MASK)) {
index e855a88d342db6da1b897d44b2069ee9500c40b1..57a05e0ba98aa20a93ae01df3666418febe8a6db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2016 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -248,7 +248,7 @@ multipath_format(const struct ofpact_multipath *mp, struct ds *s)
         algorithm = "<unknown>";
     }
 
-    ds_put_format(s, "%smultipath(%s%s,%"PRIu16",%s,%d,%"PRIu16",",
+    ds_put_format(s, "%smultipath(%s%s,%"PRIu16",%s,%d,%"PRIu32",",
                   colors.paren, colors.end, fields, mp->basis, algorithm,
                   mp->max_link + 1, mp->arg);
     mf_format_subfield(&mp->dst, s);
index a7b14ed720f901c92c315ae2a9592d71bc6f451c..874777858906f3be061b2e0aab5fffdaa5e6a9a3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -186,7 +186,7 @@ format_generic_odp_action(struct ds *ds, const struct nlattr *a)
 {
     size_t len = nl_attr_get_size(a);
 
-    ds_put_format(ds, "action%"PRId16, nl_attr_type(a));
+    ds_put_format(ds, "action%d", nl_attr_type(a));
     if (len) {
         const uint8_t *unspec;
         unsigned int i;
@@ -318,7 +318,7 @@ format_odp_userspace_action(struct ds *ds, const struct nlattr *attr)
             if (userdata_len == sizeof cookie.sflow
                 && cookie.type == USER_ACTION_COOKIE_SFLOW) {
                 ds_put_format(ds, ",sFlow("
-                              "vid=%"PRIu16",pcp=%"PRIu8",output=%"PRIu32")",
+                              "vid=%"PRIu16",pcp=%d,output=%"PRIu32")",
                               vlan_tci_to_vid(cookie.sflow.vlan_tci),
                               vlan_tci_to_pcp(cookie.sflow.vlan_tci),
                               cookie.sflow.output);
@@ -478,7 +478,7 @@ format_odp_tnl_push_header(struct ds *ds, struct ovs_action_push_tnl *data)
     l3 = eth + 1;
 
     /* Ethernet */
-    ds_put_format(ds, "header(size=%"PRIu8",type=%"PRIu8",eth(dst=",
+    ds_put_format(ds, "header(size=%"PRIu32",type=%"PRIu32",eth(dst=",
                   data->header_len, data->tnl_type);
     ds_put_format(ds, ETH_ADDR_FMT, ETH_ADDR_ARGS(eth->eth_dst));
     ds_put_format(ds, ",src=");
@@ -504,7 +504,7 @@ format_odp_tnl_push_header(struct ds *ds, struct ovs_action_push_tnl *data)
         ipv6_format_addr(&ip6->ip6_src, ds);
         ds_put_format(ds, ",dst=");
         ipv6_format_addr(&ip6->ip6_dst, ds);
-        ds_put_format(ds, ",label=%i,proto=%"PRIu8",tclass=0x%"PRIx8
+        ds_put_format(ds, ",label=%i,proto=%"PRIu8",tclass=0x%"PRIx32
                           ",hlimit=%"PRIu8"),",
                       ntohl(ip6->ip6_flow) & IPV6_LABEL_MASK, ip6->ip6_nxt,
                       (ntohl(ip6->ip6_flow) >> 20) & 0xff, ip6->ip6_hlim);
index 4e5cf8561b6b5679b04ded04867bb22f09b85ce8..be8cc20fdfd521c6748707540eb6dbba9fbdd63e 100644 (file)
@@ -1321,7 +1321,7 @@ decode_bundle(bool load, const struct nx_action_bundle *nab,
                && bundle->algorithm != NX_BD_ALG_ACTIVE_BACKUP) {
         VLOG_WARN_RL(&rl, "unsupported algorithm %d", (int) bundle->algorithm);
     } else if (slave_type != mf_nxm_header(MFF_IN_PORT)) {
-        VLOG_WARN_RL(&rl, "unsupported slave type %"PRIu16, slave_type);
+        VLOG_WARN_RL(&rl, "unsupported slave type %"PRIu32, slave_type);
     } else {
         error = 0;
     }
@@ -1355,7 +1355,7 @@ decode_bundle(bool load, const struct nx_action_bundle *nab,
     if (slaves_size < bundle->n_slaves * sizeof(ovs_be16)) {
         VLOG_WARN_RL(&rl, "Nicira action %s only has %"PRIuSIZE" bytes "
                      "allocated for slaves.  %"PRIuSIZE" bytes are required "
-                     "for %"PRIu16" slaves.",
+                     "for %u slaves.",
                      load ? "bundle_load" : "bundle", slaves_size,
                      bundle->n_slaves * sizeof(ovs_be16), bundle->n_slaves);
         error = OFPERR_OFPBAC_BAD_LEN;
@@ -3303,7 +3303,7 @@ decode_NXAST_RAW_DEC_TTL_CNT_IDS(const struct nx_action_cnt_ids *nac_ids,
     if (ids_size < ids->n_controllers * sizeof(ovs_be16)) {
         VLOG_WARN_RL(&rl, "Nicira action dec_ttl_cnt_ids only has %"PRIuSIZE" "
                      "bytes allocated for controller ids.  %"PRIuSIZE" bytes "
-                     "are required for %"PRIu16" controllers.",
+                     "are required for %u controllers.",
                      ids_size, ids->n_controllers * sizeof(ovs_be16),
                      ids->n_controllers);
         return OFPERR_OFPBAC_BAD_LEN;
@@ -4727,7 +4727,7 @@ encode_CONJUNCTION(const struct ofpact_conjunction *oc,
 static void
 format_CONJUNCTION(const struct ofpact_conjunction *oc, struct ds *s)
 {
-    ds_put_format(s, "%sconjunction(%s%"PRIu32",%"PRIu8"/%"PRIu8"%s)%s",
+    ds_put_format(s, "%sconjunction(%s%"PRIu32",%d/%"PRIu8"%s)%s",
                   colors.paren, colors.end,
                   oc->id, oc->clause + 1, oc->n_clauses,
                   colors.paren, colors.end);
@@ -5650,7 +5650,7 @@ parse_CT(char *arg, struct ofpbuf *ofpacts,
         } else if (!strcmp(key, "table")) {
             error = str_to_u8(value, "recirc_table", &oc->recirc_table);
             if (!error && oc->recirc_table == NX_CT_RECIRC_NONE) {
-                error = xasprintf("invalid table %#"PRIx16, oc->recirc_table);
+                error = xasprintf("invalid table %#"PRIx8, oc->recirc_table);
             }
         } else if (!strcmp(key, "zone")) {
             error = str_to_u16(value, "zone", &oc->zone_imm);
index 80dbf6e16e86938048ad48d48e611d4bea7641b5..8e82777fad4000e98f85d90d5cf92389837d840d 100644 (file)
@@ -875,7 +875,7 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh, int verbosity)
         ds_put_format(s, "importance:%"PRIu16" ", fm.importance);
     }
     if (fm.priority != OFP_DEFAULT_PRIORITY && need_priority) {
-        ds_put_format(s, "pri:%"PRIu16" ", fm.priority);
+        ds_put_format(s, "pri:%d ", fm.priority);
     }
     if (fm.buffer_id != UINT32_MAX) {
         ds_put_format(s, "buf:0x%"PRIx32" ", fm.buffer_id);
index 02ee95fadb2010fe2cb88f982f6e2a336db165e9..b2f96eabaac192df6f0ff10220a366eeed3e842e 100644 (file)
@@ -7101,7 +7101,7 @@ ofputil_port_from_string(const char *s, ofp_port_t *portp)
                            name, port32);
         } else if (port32 < ofp11_to_u32(OFPP11_MAX)) {
             VLOG_WARN("port %u is outside the supported range 0 through "
-                      "%"PRIx16" or 0x%x through 0x%"PRIx32, port32,
+                      "%x or 0x%x through 0x%"PRIx32, port32,
                       UINT16_MAX, ofp11_to_u32(OFPP11_MAX), UINT32_MAX);
             return false;
         } else {
index 0c5430af9d39ceeda15fa9b52d1551011fd69752..96871d1b68195b70b02c7dfb3a869ead3233a1ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, 2016 Nicira, Inc.
+ * Copyright (c) 2014, 2015, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -411,7 +411,7 @@ ovs_router_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
         if (IN6_IS_ADDR_V4MAPPED(&rt->nw_addr)) {
             plen -= 96;
         }
-        ds_put_format(&ds, "/%"PRIu16, plen);
+        ds_put_format(&ds, "/%"PRIu8, plen);
         if (rt->mark) {
             ds_put_format(&ds, " MARK %"PRIu32, rt->mark);
         }
index 1a82b8d569bebd447645aeb4a6201a0c118f0faa..7df92e58dcf537cab7d1683e52307a3c4af0cd79 100644 (file)
@@ -1942,7 +1942,7 @@ input_vid_is_valid(const struct xlate_ctx *ctx,
         if (vid) {
             xlate_report_error(ctx, "dropping VLAN %"PRIu16" tagged "
                                "packet received on port %s configured as VLAN "
-                               "%"PRIu16" access port", vid, in_xbundle->name,
+                               "%d access port", vid, in_xbundle->name,
                                in_xbundle->vlan);
             return false;
         }
index 6d199ba302614a1e4680b1f8a2e9975dc0fb3b32..692c4ddd2590f2eb355aae99e45d7e69e95dfbe4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
+ * Copyright (c) 2011, 2012, 2013, 2014, 2015, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -106,7 +106,7 @@ print_netflow(struct ofpbuf *buf)
             break;
 
         case IPPROTO_ICMP:
-            printf(", ICMP %"PRIu16":%"PRIu16,
+            printf(", ICMP %u:%u",
                    ntohs(rec->dst_port) >> 8,
                    ntohs(rec->dst_port) & 0xff);
             if (rec->src_port != htons(0)) {
index f154c52027171905a4bfb29bcb8e38a44ad1dd3a..0855fb4e08d2a64cf1cdb527260804a40f3c71bf 100644 (file)
@@ -4190,8 +4190,7 @@ ofctl_check_vlan(struct ovs_cmdl_context *ctx)
 
         printf("%04"PRIx16"/%04"PRIx16",", vid, mask);
         if (vid && vlan_tci_to_pcp(nxm_match.wc.masks.vlans[0].tci)) {
-            printf("%02"PRIx8"\n",
-                   vlan_tci_to_pcp(nxm_match.flow.vlans[0].tci));
+            printf("%02d\n", vlan_tci_to_pcp(nxm_match.flow.vlans[0].tci));
         } else {
             printf("--\n");
         }
index ce8c0d93432ba0ba02c8a768576b73944e093ed6..867a26d8de195a6548319f467922a3f916f7167c 100644 (file)
@@ -2483,7 +2483,7 @@ port_refresh_stp_status(struct port *port)
 
     /* Set Status column. */
     smap_init(&smap);
-    smap_add_format(&smap, "stp_port_id", STP_PORT_ID_FMT, status.port_id);
+    smap_add_format(&smap, "stp_port_id", "%d", status.port_id);
     smap_add(&smap, "stp_state", stp_state_name(status.state));
     smap_add_format(&smap, "stp_sec_in_state", "%u", status.sec_in_state);
     smap_add(&smap, "stp_role", stp_role_name(status.role));