From: Ben Pfaff Date: Wed, 10 Feb 2010 19:18:48 +0000 (-0800) Subject: ofproto: Avoid passing indeterminate value to rule_insert(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=212fe71c79ecb40059d01cbe6f218a5e57144c82;p=openvswitch 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). --- 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);