ofproto-dpif: Make compose_mirror_dsts() harder to screw up.
authorBen Pfaff <blp@nicira.com>
Wed, 5 Oct 2011 22:42:17 +0000 (15:42 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 17 Nov 2011 18:11:53 +0000 (10:11 -0800)
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.

ofproto/ofproto-dpif.c

index 8565a8d..400b353 100644 (file)
@@ -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;
     }
 }