From: Ben Pfaff Date: Tue, 3 Jan 2012 18:16:15 +0000 (-0800) Subject: ofproto: Make ofproto_rule_destroy__() do nothing for a null argument. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1eae3d335aad4119c6c50fbac9bf810a86886924;p=openvswitch ofproto: Make ofproto_rule_destroy__() do nothing for a null argument. This is our customary way to implement a "destroy" function. It allows a minor simplification in ofoperation_complete(). Signed-off-by: Ben Pfaff --- diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 465704b6..3dab46a4 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1655,8 +1655,10 @@ set_internal_devs_mtu(struct ofproto *p) static void ofproto_rule_destroy__(struct rule *rule) { - free(rule->actions); - rule->ofproto->ofproto_class->rule_dealloc(rule); + if (rule) { + free(rule->actions); + rule->ofproto->ofproto_class->rule_dealloc(rule); + } } /* This function allows an ofproto implementation to destroy any rules that @@ -3284,9 +3286,7 @@ ofoperation_complete(struct ofoperation *op, enum ofperr error) switch (op->type) { case OFOPERATION_ADD: if (!error) { - if (op->victim) { - ofproto_rule_destroy__(op->victim); - } + ofproto_rule_destroy__(op->victim); if ((rule->cr.wc.vlan_tci_mask & htons(VLAN_VID_MASK)) == htons(VLAN_VID_MASK)) { if (ofproto->vlan_bitmap) {