ofproto: Avoid passing indeterminate value to rule_insert().
authorBen Pfaff <blp@nicira.com>
Wed, 10 Feb 2010 19:18:48 +0000 (11:18 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 11 Feb 2010 18:35:28 +0000 (10:35 -0800)
The 'in_port' argument to rule_insert() is only used if its 'packet'
argument is nonnull, so this is not, strictly speaking, a bug, but it
seems much cleaner.

The default -1 value of in_port matches what pktbuf_retrieve() stores
there on failure.

Found by Clang (http://clang-analyzer.llvm.org).

ofproto/ofproto.c

index ecab2ad..b5f6f58 100644 (file)
@@ -2795,11 +2795,13 @@ add_flow(struct ofproto *p, struct ofconn *ofconn,
                        ntohs(ofm->hard_timeout));
     cls_rule_from_match(&rule->cr, &ofm->match, ntohs(ofm->priority));
 
-    packet = NULL;
     error = 0;
     if (ofm->buffer_id != htonl(UINT32_MAX)) {
         error = pktbuf_retrieve(ofconn->pktbuf, ntohl(ofm->buffer_id),
                                 &packet, &in_port);
+    } else {
+        packet = NULL;
+        in_port = -1;
     }
 
     rule_insert(p, rule, packet, in_port);