From 212fe71c79ecb40059d01cbe6f218a5e57144c82 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 10 Feb 2010 11:18:48 -0800 Subject: [PATCH] ofproto: Avoid passing indeterminate value to rule_insert(). 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 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index ecab2ad8..b5f6f58e 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); -- 2.30.2