From: Ben Pfaff Date: Wed, 5 Oct 2011 22:42:17 +0000 (-0700) Subject: ofproto-dpif: Make compose_mirror_dsts() harder to screw up. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb77e39b04904c8e8ae34d5bd6dd99c852018d52;p=openvswitch ofproto-dpif: Make compose_mirror_dsts() harder to screw up. I came close to add a "continue;" inside the main "while" loop in compose_mirror_dsts(), which would have turned it into an infinite loop. This commit changes it to a "for" loop that is harder to screw up. --- diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 8565a8d8..400b3532 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -4650,7 +4650,7 @@ compose_mirror_dsts(struct action_xlate_ctx *ctx, } flow_vid = vlan_tci_to_vid(ctx->flow.vlan_tci); - while (mirrors) { + for (; mirrors; mirrors &= mirrors - 1) { struct ofmirror *m = ofproto->mirrors[mirror_mask_ffs(mirrors) - 1]; if (vlan_is_mirrored(m, vlan)) { struct dst dst; @@ -4685,7 +4685,6 @@ compose_mirror_dsts(struct action_xlate_ctx *ctx, } } } - mirrors &= mirrors - 1; } }