2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-17 14:28:02 +00:00

odp-util: Use switch for checking values of an enum.

The compiler warns when we forget to handle some value of an enum, whereas
it won't for a sequence of 'if' statements.

Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Ben Pfaff
2012-05-02 14:23:28 -07:00
parent 0a18743a89
commit 21ae82ffb3
2 changed files with 13 additions and 4 deletions

View File

@@ -189,12 +189,16 @@ format_odp_userspace_action(struct ds *ds, const struct nlattr *attr)
memcpy(&cookie, &userdata, sizeof cookie);
if (cookie.type == USER_ACTION_COOKIE_SFLOW) {
switch (cookie.type) {
case USER_ACTION_COOKIE_SFLOW:
ds_put_format(ds, ",sFlow,n_output=%"PRIu8","
"vid=%"PRIu16",pcp=%"PRIu8",ifindex=%"PRIu32,
cookie.n_output, vlan_tci_to_vid(cookie.vlan_tci),
vlan_tci_to_pcp(cookie.vlan_tci), cookie.data);
} else {
break;
case USER_ACTION_COOKIE_UNSPEC:
default:
ds_put_format(ds, ",userdata=0x%"PRIx64, userdata);
}
}