From: Jesse Gross Date: Fri, 21 Oct 2011 22:19:33 +0000 (-0700) Subject: datapath: Fix uninitialized variable warning. X-Git-Tag: v1.3.0~57 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=15c39847d5a81ac6328113222c0c5a7e051b55d8;p=sliver-openvswitch.git datapath: Fix uninitialized variable warning. Commit 4edb9ae90e4092f5f56b9d914d2b88783c49860d "datapath: Refactor actions in terms of match fields." introduced a spurious warning because the compiler thinks a value might not have been assigned to 'err'. In practice this can't happen because we've already validated the actions. CC: Pravin B Shelar Signed-off-by: Jesse Gross Acked-by: Pravin B Shelar --- diff --git a/datapath/actions.c b/datapath/actions.c index 70f48eaed..8ca243dfe 100644 --- a/datapath/actions.c +++ b/datapath/actions.c @@ -311,12 +311,11 @@ static int sample(struct datapath *dp, struct sk_buff *skb, static int execute_set_action(struct sk_buff *skb, const struct nlattr *nested_attr) { - int err; + int err = 0; switch (nla_type(nested_attr)) { case OVS_KEY_ATTR_TUN_ID: OVS_CB(skb)->tun_id = nla_get_be64(nested_attr); - err = 0; break; case OVS_KEY_ATTR_ETHERNET: @@ -335,6 +334,7 @@ static int execute_set_action(struct sk_buff *skb, err = set_udp_port(skb, nla_data(nested_attr)); break; } + return err; } @@ -396,8 +396,8 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, case OVS_ACTION_ATTR_SAMPLE: err = sample(dp, skb, a); break; - } + if (unlikely(err)) { kfree_skb(skb); return err;