summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-03-17 13:38:55 -0700
committerBen Pfaff <blp@ovn.org>2017-03-17 13:39:01 -0700
commitfd13c6b549c5376745391390af663d8689e3ee6b (patch)
treebf9596ed7380c59c4cbab4a32b6b725ac182cfa8 /lib
parent59cf52e6d3307d5889335893fc941fe55cd3ed99 (diff)
downloadopenvswitch-fd13c6b549c5376745391390af663d8689e3ee6b.tar.gz
Fix format specifier technicalities.
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/bfd.c4
-rw-r--r--lib/match.c8
-rw-r--r--lib/multipath.c4
-rw-r--r--lib/odp-util.c10
-rw-r--r--lib/ofp-actions.c10
-rw-r--r--lib/ofp-print.c2
-rw-r--r--lib/ofp-util.c2
-rw-r--r--lib/ovs-router.c4
8 files changed, 22 insertions, 22 deletions
diff --git a/lib/bfd.c b/lib/bfd.c
index 87f3322ee..1fb1cfb2b 100644
--- 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
diff --git a/lib/match.c b/lib/match.c
index 4a8db187b..e50b134a8 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -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)) {
diff --git a/lib/multipath.c b/lib/multipath.c
index e855a88d3..57a05e0ba 100644
--- a/lib/multipath.c
+++ b/lib/multipath.c
@@ -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);
diff --git a/lib/odp-util.c b/lib/odp-util.c
index a7b14ed72..874777858 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -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);
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 4e5cf8561..be8cc20fd 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -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);
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 80dbf6e16..8e82777fa 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -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);
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 02ee95fad..b2f96eaba 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -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 {
diff --git a/lib/ovs-router.c b/lib/ovs-router.c
index 0c5430af9..96871d1b6 100644
--- a/lib/ovs-router.c
+++ b/lib/ovs-router.c
@@ -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);
}