Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sctp: use bitmap_weight

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>

authored by

Akinobu Mita and committed by
David S. Miller
fc184f08 67f4efdc

+2 -6
+2 -6
net/sctp/tsnmap.c
··· 272 272 __u32 max_tsn = map->max_tsn_seen; 273 273 __u32 base_tsn = map->base_tsn; 274 274 __u16 pending_data; 275 - u32 gap, i; 275 + u32 gap; 276 276 277 277 pending_data = max_tsn - cum_tsn; 278 278 gap = max_tsn - base_tsn; ··· 280 280 if (gap == 0 || gap >= map->len) 281 281 goto out; 282 282 283 - for (i = 0; i < gap+1; i++) { 284 - if (test_bit(i, map->tsn_map)) 285 - pending_data--; 286 - } 287 - 283 + pending_data -= bitmap_weight(map->tsn_map, gap + 1); 288 284 out: 289 285 return pending_data; 290 286 }