diff options
| author | Rasmus Villemoes <[email protected]> | 2015-02-12 23:02:07 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2015-02-13 02:54:14 +0000 |
| commit | df1d80a9eb16d98002673f68a7ebbe881f6e6946 (patch) | |
| tree | 354e5cd242fdd024e258f40460887d231d48e2aa /lib/string.c | |
| parent | lib/bitmap.c: change parameters of bitmap_fold to unsigned (diff) | |
| download | kernel-df1d80a9eb16d98002673f68a7ebbe881f6e6946.tar.gz kernel-df1d80a9eb16d98002673f68a7ebbe881f6e6946.zip | |
lib/bitmap.c: simplify bitmap_pos_to_ord
The ordinal of a set bit is simply the number of set bits before it;
counting those doesn't need to be done one bit at a time. While at it,
update the parameters to unsigned int.
It is not completely unthinkable that gcc would see pos as compile-time
constant 0 in one of the uses of bitmap_pos_to_ord. Since the static
inline frontend bitmap_weight doesn't handle nbits==0 correctly (it would
behave exactly as if nbits==BITS_PER_LONG), use __bitmap_weight.
Alternatively, the last line could be spelled bitmap_weight(buf, pos+1)-1,
but this is simpler.
Signed-off-by: Rasmus Villemoes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'lib/string.c')
0 files changed, 0 insertions, 0 deletions
