Skip to content

Commit

Permalink
sctp: use bitmap_weight
Browse files Browse the repository at this point in the history
Use bitmap_weight to count the total number of bits set in bitmap.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>
Cc: Sridhar Samudrala <sri@us.ibm.com>
Cc: linux-sctp@vger.kernel.org
Cc: netdev@vger.kernel.org
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Akinobu Mita authored and David S. Miller committed Nov 18, 2012
1 parent 67f4efd commit fc184f0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions net/sctp/tsnmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,15 @@ __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map)
__u32 max_tsn = map->max_tsn_seen;
__u32 base_tsn = map->base_tsn;
__u16 pending_data;
u32 gap, i;
u32 gap;

pending_data = max_tsn - cum_tsn;
gap = max_tsn - base_tsn;

if (gap == 0 || gap >= map->len)
goto out;

for (i = 0; i < gap+1; i++) {
if (test_bit(i, map->tsn_map))
pending_data--;
}

pending_data -= bitmap_weight(map->tsn_map, gap + 1);
out:
return pending_data;
}
Expand Down

0 comments on commit fc184f0

Please sign in to comment.