Although ofp_port_t uses a 16-bit range, it is defined as a 32-bit type.
The format strings throughout the code base were using PRIu16 for
ofp_port_t which leads to the compiler to throw Wformat message on
platforms that don't promote 16-bit to 32-bit integers, e.g., on macOS.

Signed-off-by: Shu Shen <[email protected]>
---
 lib/bundle.c                 |  2 +-
 lib/learning-switch.c        |  2 +-
 lib/ofp-actions.c            |  6 +++---
 lib/ofp-util.c               |  4 ++--
 ofproto/ofproto-dpif-xlate.c |  2 +-
 ofproto/ofproto-dpif.c       |  2 +-
 ofproto/ofproto.c            | 30 +++++++++++++++---------------
 7 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/lib/bundle.c b/lib/bundle.c
index 7fc02e204..70a743b17 100644
--- a/lib/bundle.c
+++ b/lib/bundle.c
@@ -123,7 +123,7 @@ bundle_check(const struct ofpact_bundle *bundle, ofp_port_t 
max_ports,
         if (ofp_port != OFPP_NONE) {
             enum ofperr error = ofpact_check_output_port(ofp_port, max_ports);
             if (error) {
-                VLOG_WARN_RL(&rl, "invalid slave %"PRIu16, ofp_port);
+                VLOG_WARN_RL(&rl, "invalid slave %"PRIu32, ofp_port);
                 return error;
             }
         }
diff --git a/lib/learning-switch.c b/lib/learning-switch.c
index 30aab1210..bc757f46d 100644
--- a/lib/learning-switch.c
+++ b/lib/learning-switch.c
@@ -451,7 +451,7 @@ lswitch_choose_destination(struct lswitch *sw, const struct 
flow *flow)
             if (get_mac_entry_ofp_port(sw->ml, mac)
                 != flow->in_port.ofp_port) {
                 VLOG_DBG_RL(&rl, "%016llx: learned that "ETH_ADDR_FMT" is on "
-                            "port %"PRIu16, sw->datapath_id,
+                            "port %"PRIu32, sw->datapath_id,
                             ETH_ADDR_ARGS(flow->dl_src),
                             flow->in_port.ofp_port);
 
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 47365215c..cf1ad0fa9 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -645,7 +645,7 @@ static void
 format_OUTPUT(const struct ofpact_output *a, struct ds *s)
 {
     if (ofp_to_u16(a->port) < ofp_to_u16(OFPP_MAX)) {
-        ds_put_format(s, "%soutput:%s%"PRIu16,
+        ds_put_format(s, "%soutput:%s%"PRIu32,
                       colors.special, colors.end, a->port);
     } else {
         ofputil_format_port(a->port, s);
@@ -5077,7 +5077,7 @@ format_SAMPLE(const struct ofpact_sample *a, struct ds *s)
                   colors.param, colors.end, a->obs_domain_id,
                   colors.param, colors.end, a->obs_point_id);
     if (a->sampling_port != OFPP_NONE) {
-        ds_put_format(s, ",%ssampling_port=%s%"PRIu16,
+        ds_put_format(s, ",%ssampling_port=%s%"PRIu32,
                       colors.param, colors.end, a->sampling_port);
     }
     if (a->direction == NX_ACTION_SAMPLE_INGRESS) {
@@ -5933,7 +5933,7 @@ parse_OUTPUT_TRUNC(const char *arg, struct ofpbuf 
*ofpacts OVS_UNUSED,
 static void
 format_OUTPUT_TRUNC(const struct ofpact_output_trunc *a, struct ds *s)
 {
-     ds_put_format(s, "%soutput%s(port=%"PRIu16",max_len=%"PRIu32")",
+     ds_put_format(s, "%soutput%s(port=%"PRIu32",max_len=%"PRIu32")",
                    colors.special, colors.end, a->port, a->max_len);
 }
 
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 305fa3730..b5e294bff 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -4193,7 +4193,7 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po,
     if (ofp_to_u16(po->in_port) >= ofp_to_u16(OFPP_MAX)
         && po->in_port != OFPP_LOCAL
         && po->in_port != OFPP_NONE && po->in_port != OFPP_CONTROLLER) {
-        VLOG_WARN_RL(&bad_ofmsg_rl, "packet-out has bad input port %#"PRIx16,
+        VLOG_WARN_RL(&bad_ofmsg_rl, "packet-out has bad input port %#"PRIx32,
                      po->in_port);
         return OFPERR_OFPBRC_BAD_PORT;
     }
@@ -7123,7 +7123,7 @@ ofputil_port_to_string(ofp_port_t port,
 #undef OFPUTIL_NAMED_PORT
 
     default:
-        snprintf(namebuf, bufsize, "%"PRIu16, port);
+        snprintf(namebuf, bufsize, "%"PRIu32, port);
         break;
     }
 }
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index e02771edb..9a15ec382 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1749,7 +1749,7 @@ lookup_input_bundle(const struct xlate_ctx *ctx,
          *   the port after it was created, but before the client had a chance
          *   to configure its bundle.
          */
-        xlate_report_error(ctx, "received packet on unknown port %"PRIu16,
+        xlate_report_error(ctx, "received packet on unknown port %"PRIu32,
                            in_port);
     }
     return xbundle;
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 3b274eebb..72e91b941 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3882,7 +3882,7 @@ rule_dpif_lookup_from_table(struct ofproto_dpif *ofproto,
 
             port = ofp_port_to_ofport(ofproto, old_in_port);
             if (!port) {
-                VLOG_WARN_RL(&rl, "packet-in on unknown OpenFlow port %"PRIu16,
+                VLOG_WARN_RL(&rl, "packet-in on unknown OpenFlow port %"PRIu32,
                              old_in_port);
             } else if (!(port->up.pp.config & OFPUTIL_PC_NO_PACKET_IN)) {
                 rule = ofproto->miss_rule;
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 5f21efc45..0b5e0fa8e 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -954,7 +954,7 @@ ofproto_port_set_stp(struct ofproto *ofproto, ofp_port_t 
ofp_port,
 {
     struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
-        VLOG_WARN("%s: cannot configure STP on nonexistent port %"PRIu16,
+        VLOG_WARN("%s: cannot configure STP on nonexistent port %"PRIu32,
                   ofproto->name, ofp_port);
         return ENODEV;
     }
@@ -976,7 +976,7 @@ ofproto_port_get_stp_status(struct ofproto *ofproto, 
ofp_port_t ofp_port,
     struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
         VLOG_WARN_RL(&rl, "%s: cannot get STP status on nonexistent "
-                     "port %"PRIu16, ofproto->name, ofp_port);
+                     "port %"PRIu32, ofproto->name, ofp_port);
         return ENODEV;
     }
 
@@ -997,7 +997,7 @@ ofproto_port_get_stp_stats(struct ofproto *ofproto, 
ofp_port_t ofp_port,
     struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
         VLOG_WARN_RL(&rl, "%s: cannot get STP stats on nonexistent "
-                     "port %"PRIu16, ofproto->name, ofp_port);
+                     "port %"PRIu32, ofproto->name, ofp_port);
         return ENODEV;
     }
 
@@ -1052,7 +1052,7 @@ ofproto_port_set_rstp(struct ofproto *ofproto, ofp_port_t 
ofp_port,
 {
     struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
-        VLOG_WARN("%s: cannot configure RSTP on nonexistent port %"PRIu16,
+        VLOG_WARN("%s: cannot configure RSTP on nonexistent port %"PRIu32,
                 ofproto->name, ofp_port);
         return ENODEV;
     }
@@ -1076,7 +1076,7 @@ ofproto_port_get_rstp_status(struct ofproto *ofproto, 
ofp_port_t ofp_port,
     struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
         VLOG_WARN_RL(&rl, "%s: cannot get RSTP status on nonexistent "
-                "port %"PRIu16, ofproto->name, ofp_port);
+                "port %"PRIu32, ofproto->name, ofp_port);
         return ENODEV;
     }
 
@@ -1104,7 +1104,7 @@ ofproto_port_set_queues(struct ofproto *ofproto, 
ofp_port_t ofp_port,
     struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
 
     if (!ofport) {
-        VLOG_WARN("%s: cannot set queues on nonexistent port %"PRIu16,
+        VLOG_WARN("%s: cannot set queues on nonexistent port %"PRIu32,
                   ofproto->name, ofp_port);
         return ENODEV;
     }
@@ -1125,7 +1125,7 @@ ofproto_port_set_lldp(struct ofproto *ofproto,
 
     ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
-        VLOG_WARN("%s: cannot configure LLDP on nonexistent port %"PRIu16,
+        VLOG_WARN("%s: cannot configure LLDP on nonexistent port %"PRIu32,
                   ofproto->name, ofp_port);
         return;
     }
@@ -1133,7 +1133,7 @@ ofproto_port_set_lldp(struct ofproto *ofproto,
              ? ofproto->ofproto_class->set_lldp(ofport, cfg)
              : EOPNOTSUPP);
     if (error) {
-        VLOG_WARN("%s: lldp configuration on port %"PRIu16" (%s) failed (%s)",
+        VLOG_WARN("%s: lldp configuration on port %"PRIu32" (%s) failed (%s)",
                   ofproto->name, ofp_port, netdev_get_name(ofport->netdev),
                   ovs_strerror(error));
     }
@@ -1218,7 +1218,7 @@ ofproto_port_set_cfm(struct ofproto *ofproto, ofp_port_t 
ofp_port,
 
     ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
-        VLOG_WARN("%s: cannot configure CFM on nonexistent port %"PRIu16,
+        VLOG_WARN("%s: cannot configure CFM on nonexistent port %"PRIu32,
                   ofproto->name, ofp_port);
         return;
     }
@@ -1230,7 +1230,7 @@ ofproto_port_set_cfm(struct ofproto *ofproto, ofp_port_t 
ofp_port,
              ? ofproto->ofproto_class->set_cfm(ofport, s)
              : EOPNOTSUPP);
     if (error) {
-        VLOG_WARN("%s: CFM configuration on port %"PRIu16" (%s) failed (%s)",
+        VLOG_WARN("%s: CFM configuration on port %"PRIu32" (%s) failed (%s)",
                   ofproto->name, ofp_port, netdev_get_name(ofport->netdev),
                   ovs_strerror(error));
     }
@@ -1247,7 +1247,7 @@ ofproto_port_set_bfd(struct ofproto *ofproto, ofp_port_t 
ofp_port,
 
     ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
-        VLOG_WARN("%s: cannot configure bfd on nonexistent port %"PRIu16,
+        VLOG_WARN("%s: cannot configure bfd on nonexistent port %"PRIu32,
                   ofproto->name, ofp_port);
         return;
     }
@@ -1256,7 +1256,7 @@ ofproto_port_set_bfd(struct ofproto *ofproto, ofp_port_t 
ofp_port,
              ? ofproto->ofproto_class->set_bfd(ofport, cfg)
              : EOPNOTSUPP);
     if (error) {
-        VLOG_WARN("%s: bfd configuration on port %"PRIu16" (%s) failed (%s)",
+        VLOG_WARN("%s: bfd configuration on port %"PRIu32" (%s) failed (%s)",
                   ofproto->name, ofp_port, netdev_get_name(ofport->netdev),
                   ovs_strerror(error));
     }
@@ -2069,7 +2069,7 @@ ofproto_port_set_config(struct ofproto *ofproto, 
ofp_port_t ofp_port,
 
     ofport = ofproto_get_port(ofproto, ofp_port);
     if (!ofport) {
-        VLOG_WARN("%s: cannot configure datapath on nonexistent port %"PRIu16,
+        VLOG_WARN("%s: cannot configure datapath on nonexistent port %"PRIu32,
                   ofproto->name, ofp_port);
         return;
     }
@@ -2078,7 +2078,7 @@ ofproto_port_set_config(struct ofproto *ofproto, 
ofp_port_t ofp_port,
              ? ofproto->ofproto_class->port_set_config(ofport, cfg)
              : EOPNOTSUPP);
     if (error) {
-        VLOG_WARN("%s: datapath configuration on port %"PRIu16
+        VLOG_WARN("%s: datapath configuration on port %"PRIu32
                   " (%s) failed (%s)",
                   ofproto->name, ofp_port, netdev_get_name(ofport->netdev),
                   ovs_strerror(error));
@@ -2311,7 +2311,7 @@ ofport_open(struct ofproto *ofproto,
 
     error = netdev_open(ofproto_port->name, ofproto_port->type, &netdev);
     if (error) {
-        VLOG_WARN_RL(&rl, "%s: ignoring port %s (%"PRIu16") because netdev %s "
+        VLOG_WARN_RL(&rl, "%s: ignoring port %s (%"PRIu32") because netdev %s "
                      "cannot be opened (%s)",
                      ofproto->name,
                      ofproto_port->name, ofproto_port->ofp_port,
-- 
2.11.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to