ofproto: Initialise return value of modify_flows__
authorSimon Horman <horms@verge.net.au>
Fri, 13 Jun 2014 02:06:09 +0000 (11:06 +0900)
committerBen Pfaff <blp@nicira.com>
Fri, 13 Jun 2014 17:44:36 +0000 (10:44 -0700)
dd51dae29bccca3 ("ofproto: Move logic for collecting read-only rules into
rule_criteria.") modifies modify_flows__ such that the variable error,
the return value, may be uninitialised if either of the following is true:

1. ofproto->ofproto_class->rule_premodify_actions is NULL
2. rules->n is zero

It appears for the "bfd - Verify tunnel down detection" test
in the testsuite the first condition is true and the test fails.

This commit fixes the problem.

Signed-off-by: Simon Horman <horms@verge.net.au>
[blp@nicira.com changed the style of the fix]
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto.c

index a3ab276..b0d5cc8 100644 (file)
@@ -4099,12 +4099,12 @@ modify_flows__(struct ofproto *ofproto, struct ofputil_flow_mod *fm,
 {
     struct list dead_cookies = LIST_INITIALIZER(&dead_cookies);
     enum nx_flow_update_event event;
-    enum ofperr error;
     size_t i;
 
     if (ofproto->ofproto_class->rule_premodify_actions) {
         for (i = 0; i < rules->n; i++) {
             struct rule *rule = rules->rules[i];
+            enum ofperr error;
 
             error = ofproto->ofproto_class->rule_premodify_actions(
                 rule, fm->ofpacts, fm->ofpacts_len);
@@ -4187,11 +4187,11 @@ modify_flows__(struct ofproto *ofproto, struct ofputil_flow_mod *fm,
     learned_cookies_flush(ofproto, &dead_cookies);
 
     if (fm->buffer_id != UINT32_MAX && req) {
-        error = send_buffered_packet(req->ofconn, fm->buffer_id,
-                                     rules->rules[0]);
+        return send_buffered_packet(req->ofconn, fm->buffer_id,
+                                    rules->rules[0]);
     }
 
-    return error;
+    return 0;
 }
 
 static enum ofperr