From patchwork Tue Mar 7 23:56:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 736405 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vdD8g67vQz9sNJ for ; Wed, 8 Mar 2017 10:56:51 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 91E81C57; Tue, 7 Mar 2017 23:56:48 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 702FEBE0 for ; Tue, 7 Mar 2017 23:56:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 23933185 for ; Tue, 7 Mar 2017 23:56:46 +0000 (UTC) Received: from mfilter18-d.gandi.net (mfilter18-d.gandi.net [217.70.178.146]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id DB5F7A80CD; Wed, 8 Mar 2017 00:56:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter18-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter18-d.gandi.net (mfilter18-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id b-zjFgAxZssq; Wed, 8 Mar 2017 00:56:42 +0100 (CET) X-Originating-IP: 208.91.2.3 Received: from sigabrt.benpfaff.org (unknown [208.91.2.3]) (Authenticated sender: blp@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 64FC2A80C6; Wed, 8 Mar 2017 00:56:39 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Tue, 7 Mar 2017 15:56:34 -0800 Message-Id: <20170307235634.11058-1-blp@ovn.org> X-Mailer: git-send-email 2.10.2 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH] Fix format specifier technicalities. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 Signed-off-by: Ben Pfaff Acked-by: Daniele Di Proietto --- lib/bfd.c | 4 ++-- lib/match.c | 6 +++--- lib/multipath.c | 4 ++-- lib/odp-util.c | 10 +++++----- lib/ofp-actions.c | 12 ++++++------ lib/ofp-print.c | 2 +- lib/ofp-util.c | 2 +- lib/ovs-router.c | 4 ++-- ofproto/ofproto-dpif-xlate.c | 2 +- tests/test-netflow.c | 4 ++-- utilities/ovs-ofctl.c | 2 +- vswitchd/bridge.c | 4 ++-- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/bfd.c b/lib/bfd.c index 87f3322ee461..1fb1cfb2bc34 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 3fcaec5b08ca..6bbd34820aa1 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. @@ -1281,11 +1281,11 @@ match_format(const struct match *match, struct ds *s, int priority) 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 8a1d1fadcf74..7eb919423a15 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 = ""; } - 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 a8218566e05e..527496e4d68f 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. @@ -183,7 +183,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; @@ -315,7 +315,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); @@ -475,7 +475,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="); @@ -501,7 +501,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 ce80f57e8df3..01dc571de584 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -1312,7 +1312,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; } @@ -1345,7 +1345,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; @@ -1716,7 +1716,7 @@ static void format_PUSH_VLAN(const struct ofpact_null *a OVS_UNUSED, struct ds *s) { /* XXX 802.1AD case*/ - ds_put_format(s, "%spush_vlan:%s%#"PRIx16, + ds_put_format(s, "%spush_vlan:%s%#x", colors.param, colors.end, ETH_TYPE_VLAN_8021Q); } @@ -3271,7 +3271,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; @@ -4554,7 +4554,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); @@ -5455,7 +5455,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 f7f7df26f5e1..3c357f7df863 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 0c9343ec400b..a8f4ae333e98 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -7064,7 +7064,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 0c5430af9d39..96871d1b6819 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); } diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index eda34f044192..de4ad0faa0fc 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1909,7 +1909,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; } diff --git a/tests/test-netflow.c b/tests/test-netflow.c index 6d199ba30261..692c4ddd2590 100644 --- a/tests/test-netflow.c +++ b/tests/test-netflow.c @@ -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)) { diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 77332e0f8c16..83fbf8a1c7f8 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -4189,7 +4189,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.vlan_tci)) { - printf("%02"PRIx8"\n", vlan_tci_to_pcp(nxm_match.flow.vlan_tci)); + printf("%02x\n", vlan_tci_to_pcp(nxm_match.flow.vlan_tci)); } else { printf("--\n"); } diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 2e1001350954..3d9774a69b26 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc. +/* Copyright (c) 2008, 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. @@ -2468,7 +2468,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));