datapath: Fix uninitialized variable warning.
authorJesse Gross <jesse@nicira.com>
Fri, 21 Oct 2011 22:19:33 +0000 (15:19 -0700)
committerJesse Gross <jesse@nicira.com>
Fri, 21 Oct 2011 22:55:43 +0000 (15:55 -0700)
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 <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
datapath/actions.c

index 70f48eaed3c412f215690addec95533d668be9dd..8ca243dfe6932a81f62a9c5defe4337f9c6953ba 100644 (file)
@@ -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;