Looks good.

--Justin


On May 5, 2012, at 11:10 AM, Ben Pfaff wrote:

> 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 <[email protected]>
> ---
> lib/odp-util.c         |    8 ++++++--
> ofproto/ofproto-dpif.c |    9 +++++++--
> 2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index 36ea5a4..8d0e95f 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -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);
>         }
>     }
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index 52a7412..5a8edcd 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -3031,13 +3031,18 @@ handle_userspace_upcall(struct ofproto_dpif *ofproto,
>         return;
>     }
> 
> -    if (cookie.type == USER_ACTION_COOKIE_SFLOW) {
> +    switch (cookie.type) {
> +    case USER_ACTION_COOKIE_SFLOW:
>         if (ofproto->sflow) {
>             dpif_sflow_received(ofproto->sflow, upcall->packet, &flow,
>                                 &cookie);
>         }
> -    } else {
> +        break;
> +
> +    case USER_ACTION_COOKIE_UNSPEC:
> +    default:
>         VLOG_WARN_RL(&rl, "invalid user cookie : 0x%"PRIx64, 
> upcall->userdata);
> +        break;
>     }
> }
> 
> -- 
> 1.7.2.5
> 
> _______________________________________________
> dev mailing list
> [email protected]
> http://openvswitch.org/mailman/listinfo/dev

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to