Skip to content

Commit

Permalink
bridge: using for_each_set_bit to simplify the code
Browse files Browse the repository at this point in the history
Using for_each_set_bit() to simplify the code.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Wei Yongjun authored and David S. Miller committed Mar 12, 2013
1 parent 5096e3c commit 74694e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
10 changes: 2 additions & 8 deletions net/bridge/br_fdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,10 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
* specify a VLAN. To be nice, add/update entry for every
* vlan on this port.
*/
vid = find_first_bit(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN);
while (vid < BR_VLAN_BITMAP_LEN) {
for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
err = __br_fdb_add(ndm, p, addr, nlh_flags, vid);
if (err)
goto out;
vid = find_next_bit(pv->vlan_bitmap,
BR_VLAN_BITMAP_LEN, vid+1);
}
}

Expand Down Expand Up @@ -813,11 +810,8 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
* vlan on this port.
*/
err = -ENOENT;
vid = find_first_bit(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN);
while (vid < BR_VLAN_BITMAP_LEN) {
for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
err &= __br_fdb_delete(p, addr, vid);
vid = find_next_bit(pv->vlan_bitmap,
BR_VLAN_BITMAP_LEN, vid+1);
}
}
out:
Expand Down
5 changes: 1 addition & 4 deletions net/bridge/br_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
goto nla_put_failure;

pvid = br_get_pvid(pv);
for (vid = find_first_bit(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN);
vid < BR_VLAN_BITMAP_LEN;
vid = find_next_bit(pv->vlan_bitmap,
BR_VLAN_BITMAP_LEN, vid+1)) {
for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
vinfo.vid = vid;
vinfo.flags = 0;
if (vid == pvid)
Expand Down

0 comments on commit 74694e7

Please sign in to comment.