From 4b6ab2b0ae49194e4ff78cc005921286aa9be140 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 18 Dec 2013 09:20:49 -0800 Subject: [PATCH] ofproto-dpif: Get rid of mirror_mask_ffs() function. There's no need for it because we have the equivalent (actually more convenient) function raw_ctz(), which works with any integer type. Signed-off-by: Ben Pfaff CC: Alin Serdean CC: Gurucharan Shetty --- ofproto/ofproto-dpif-mirror.c | 3 +-- ofproto/ofproto-dpif-mirror.h | 6 ------ ofproto/ofproto-dpif-xlate.c | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/ofproto/ofproto-dpif-mirror.c b/ofproto/ofproto-dpif-mirror.c index 0819b726e..99172dd55 100644 --- a/ofproto/ofproto-dpif-mirror.c +++ b/ofproto/ofproto-dpif-mirror.c @@ -75,7 +75,6 @@ static void mbundle_lookup_multiple(const struct mbridge *, struct ofbundle **, size_t n_bundles, struct hmapx *mbundles); static int mirror_scan(struct mbridge *); static void mirror_update_dups(struct mbridge *); -static int mirror_mask_ffs(mirror_mask_t); struct mbridge * mbridge_create(void) @@ -363,7 +362,7 @@ mirror_update_stats(struct mbridge *mbridge, mirror_mask_t mirrors, for (; mirrors; mirrors = zero_rightmost_1bit(mirrors)) { struct mirror *m; - m = mbridge->mirrors[mirror_mask_ffs(mirrors) - 1]; + m = mbridge->mirrors[raw_ctz(mirrors)]; if (!m) { /* In normal circumstances 'm' will not be NULL. However, diff --git a/ofproto/ofproto-dpif-mirror.h b/ofproto/ofproto-dpif-mirror.h index 4a6f3cebd..64c456123 100644 --- a/ofproto/ofproto-dpif-mirror.h +++ b/ofproto/ofproto-dpif-mirror.h @@ -52,10 +52,4 @@ bool mirror_get(struct mbridge *, int index, unsigned long **vlans, mirror_mask_t *dup_mirrors, struct ofbundle **out, int *out_vlan); -static inline int -mirror_mask_ffs(mirror_mask_t mask) -{ - BUILD_ASSERT_DECL(sizeof(unsigned int) >= sizeof(mask)); - return ffs(mask); -} #endif /* ofproto-dpif-mirror.h */ diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index ab8122639..09406b72a 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -968,7 +968,7 @@ add_mirror_actions(struct xlate_ctx *ctx, const struct flow *orig_flow) bool has_mirror; int out_vlan; - has_mirror = mirror_get(xbridge->mbridge, mirror_mask_ffs(mirrors) - 1, + has_mirror = mirror_get(xbridge->mbridge, raw_ctz(mirrors), &vlans, &dup_mirrors, &out, &out_vlan); ovs_assert(has_mirror); -- 2.20.1