On Tue, Mar 07, 2017 at 05:11:28AM -0800, nickcooper-zhangtonghao wrote:
> The stp/show command will help users and developers get
> more details about stp. This patch works together with
> the previous patch "stp: Change the api for next patch."
> 
> Signed-off-by: nickcooper-zhangtonghao <[email protected]>

Thanks for working on this!

I noticed that a lot of the printf format specifiers seem to be randomly
chosen.  I'm appending a patch that fixes these and improves style in a
couple of ways.

This patch should also add documentation for the new commands in the
ovs-vswitchd manpage and probably add a NEWS item too.  Will you send a
revision?

Thanks,

Ben.

--8<--------------------------cut here-------------------------->8--

diff --git a/lib/stp.c b/lib/stp.c
index d90b400f168d..8626f24e1c01 100644
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -1645,20 +1645,17 @@ stp_bridge_id_details(struct ds *ds, const 
stp_identifier bridge_id,
                       const int forward_delay)
     OVS_REQUIRES(mutex)
 {
+    uint16_t priority = bridge_id >> 48;
+    ds_put_format(ds, "\tstp-priority\t%"PRIu16"\n", priority);
+
     struct eth_addr mac;
     const uint64_t mac_bits = (UINT64_C(1) << 48) - 1;
-
-    ds_put_format(ds, "\tstp-priority\t%"PRIu32"\n",
-                  (uint16_t)(bridge_id >> 48));
-
     eth_addr_from_uint64(bridge_id & mac_bits, &mac);
-    ds_put_format(ds, "\tstp-system-id\t"ETH_ADDR_FMT"\n",
-                  ETH_ADDR_ARGS(mac));
-    ds_put_format(ds, "\tstp-hello-time\t%"PRId32"s\n",
+    ds_put_format(ds, "\tstp-system-id\t"ETH_ADDR_FMT"\n", ETH_ADDR_ARGS(mac));
+    ds_put_format(ds, "\tstp-hello-time\t%ds\n",
                   timer_to_ms(hello_time) / 1000);
-    ds_put_format(ds, "\tstp-max-age\t%"PRId32"s\n",
-                  timer_to_ms(max_age) / 1000);
-    ds_put_format(ds, "\tstp-fwd-delay\t%"PRId32"s\n",
+    ds_put_format(ds, "\tstp-max-age\t%ds\n", timer_to_ms(max_age) / 1000);
+    ds_put_format(ds, "\tstp-fwd-delay\t%ds\n",
                   timer_to_ms(forward_delay) / 1000);
 }
 
@@ -1671,27 +1668,21 @@ stp_print_details(struct ds *ds, const struct stp *stp)
     ds_put_format(ds, "---- %s ----\n", stp->name);
     ds_put_cstr(ds, "Root ID:\n");
 
-    stp_bridge_id_details(ds, stp->designated_root,
-                          stp->bridge_hello_time,
-                          stp->bridge_max_age,
-                          stp->bridge_forward_delay);
+    stp_bridge_id_details(ds, stp->designated_root, stp->bridge_hello_time,
+                          stp->bridge_max_age, stp->bridge_forward_delay);
 
     if (stp_is_root_bridge(stp)) {
         ds_put_cstr(ds, "\tThis bridge is the root\n");
     } else {
-        ds_put_format(ds, "\troot-port\t%s\n",
-                      stp->root_port->port_name);
-        ds_put_format(ds, "\troot-path-cost\t%"PRIu32"\n",
-                      stp->root_path_cost);
+        ds_put_format(ds, "\troot-port\t%s\n", stp->root_port->port_name);
+        ds_put_format(ds, "\troot-path-cost\t%u\n", stp->root_path_cost);
     }
 
     ds_put_cstr(ds, "\n");
 
     ds_put_cstr(ds, "Bridge ID:\n");
-    stp_bridge_id_details(ds, stp->bridge_id,
-                          stp->hello_time,
-                          stp->max_age,
-                          stp->forward_delay);
+    stp_bridge_id_details(ds, stp->bridge_id, stp->hello_time,
+                          stp->max_age, stp->forward_delay);
 
     ds_put_cstr(ds, "\n");
 
@@ -1703,8 +1694,8 @@ stp_print_details(struct ds *ds, const struct stp *stp)
         ds_put_format(ds, "\t%-11.10s", p->port_name);
         ds_put_format(ds, "%-11.10s", stp_role_name(stp_port_get_role(p)));
         ds_put_format(ds, "%-11.10s", stp_state_name(p->state));
-        ds_put_format(ds, "%-6"PRId32, p->path_cost);
-        ds_put_format(ds, "%"PRIu16".%"PRIu16"\n",
+        ds_put_format(ds, "%-6d", p->path_cost);
+        ds_put_format(ds, "%d.%d\n",
                       p->port_id >> 8,
                       p->port_id & port_no_bits);
     }
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to