[ovs-dev] [PATCH 13/15] ofproto: Avoid passing indeterminate value to rule_insert().

Ben Pfaff blp at nicira.com
Wed Feb 10 19:30:36 UTC 2010


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 |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index ecab2ad..b5f6f58 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -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);
-- 
1.6.6.1





More information about the dev mailing list