odp-util: Limit scope of vlan in format_odp_action().
authorSimon Horman <simon.horman@netronome.com>
Tue, 1 Dec 2015 06:03:02 +0000 (15:03 +0900)
committerBen Pfaff <blp@ovn.org>
Tue, 1 Dec 2015 18:26:35 +0000 (10:26 -0800)
Limit the scope of the local vlan variable in format_odp_action()
to where it is used. This is consistent with the treatment of mpls
in the same function.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/odp-util.c

index 5ed77b5..32c813b 100644 (file)
@@ -755,7 +755,6 @@ format_odp_action(struct ds *ds, const struct nlattr *a)
 {
     int expected_len;
     enum ovs_action_attr type = nl_attr_type(a);
-    const struct ovs_action_push_vlan *vlan;
     size_t size;
 
     expected_len = odp_action_len(nl_attr_type(a));
@@ -813,8 +812,8 @@ format_odp_action(struct ds *ds, const struct nlattr *a)
         format_odp_key_attr(nl_attr_get(a), NULL, NULL, ds, true);
         ds_put_cstr(ds, ")");
         break;
-    case OVS_ACTION_ATTR_PUSH_VLAN:
-        vlan = nl_attr_get(a);
+    case OVS_ACTION_ATTR_PUSH_VLAN: {
+        const struct ovs_action_push_vlan *vlan = nl_attr_get(a);
         ds_put_cstr(ds, "push_vlan(");
         if (vlan->vlan_tpid != htons(ETH_TYPE_VLAN)) {
             ds_put_format(ds, "tpid=0x%04"PRIx16",", ntohs(vlan->vlan_tpid));
@@ -822,6 +821,7 @@ format_odp_action(struct ds *ds, const struct nlattr *a)
         format_vlan_tci(ds, vlan->vlan_tci, OVS_BE16_MAX, false);
         ds_put_char(ds, ')');
         break;
+    }
     case OVS_ACTION_ATTR_POP_VLAN:
         ds_put_cstr(ds, "pop_vlan");
         break;