Skip to content

Commit f767ab0

Browse files
committed
docs bitwalk: fixup some document issues
Signed-off-by: John Sanpe <sanpeqf@gmail.com>
1 parent af21b52 commit f767ab0

2 files changed

Lines changed: 27 additions & 21 deletions

File tree

include/bfdev/bitwalk.h

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ bfdev_find_first_bit(const unsigned long *addr, unsigned int bits)
2828
{
2929
unsigned long value;
3030

31-
if (!bfdev_const_small_nbits(bits))
32-
return bfdev_comp_find_first_bit(addr, bits, 0UL, bfdev_false);
31+
if (!bfdev_const_small_nbits(bits)) {
32+
return bfdev_comp_find_first_bit(addr, bits,
33+
BFDEV_ULONG_MIN, bfdev_false);
34+
}
3335

3436
value = *addr & BFDEV_BIT_LOW_MASK(bits);
3537
if (value == BFDEV_ULONG_MIN)
@@ -45,8 +47,10 @@ bfdev_find_last_bit(const unsigned long *addr, unsigned int bits)
4547
{
4648
unsigned long value;
4749

48-
if (!bfdev_const_small_nbits(bits))
49-
return bfdev_comp_find_last_bit(addr, bits, 0UL, bfdev_false);
50+
if (!bfdev_const_small_nbits(bits)) {
51+
return bfdev_comp_find_last_bit(addr, bits,
52+
BFDEV_ULONG_MIN, bfdev_false);
53+
}
5054

5155
value = *addr & BFDEV_BIT_LOW_MASK(bits);
5256
if (value == BFDEV_ULONG_MIN)
@@ -70,8 +74,10 @@ bfdev_find_first_zero(const unsigned long *addr, unsigned int bits)
7074
{
7175
unsigned long value;
7276

73-
if (!bfdev_const_small_nbits(bits))
74-
return bfdev_comp_find_first_bit(addr, bits, ~0UL, bfdev_false);
77+
if (!bfdev_const_small_nbits(bits)) {
78+
return bfdev_comp_find_first_bit(addr, bits,
79+
BFDEV_ULONG_MAX, bfdev_false);
80+
}
7581

7682
value = *addr | BFDEV_BIT_HIGH_MASK(bits);
7783
if (value == BFDEV_ULONG_MAX)
@@ -87,8 +93,10 @@ bfdev_find_last_zero(const unsigned long *addr, unsigned int bits)
8793
{
8894
unsigned long value;
8995

90-
if (!bfdev_const_small_nbits(bits))
91-
return bfdev_comp_find_last_bit(addr, bits, ~0UL, bfdev_false);
96+
if (!bfdev_const_small_nbits(bits)) {
97+
return bfdev_comp_find_last_bit(addr, bits,
98+
BFDEV_ULONG_MAX, bfdev_false);
99+
}
92100

93101
value = *addr | BFDEV_BIT_HIGH_MASK(bits);
94102
if (value == BFDEV_ULONG_MAX)
@@ -116,7 +124,7 @@ bfdev_find_next_bit(const unsigned long *addr,
116124

117125
if (!bfdev_const_small_nbits(bits)) {
118126
return bfdev_comp_find_next_bit(addr, BFDEV_NULL,
119-
bits, offset, 0UL, bfdev_false);
127+
bits, offset, BFDEV_ULONG_MIN, bfdev_false);
120128
}
121129

122130
if (bfdev_unlikely(offset >= bits))
@@ -139,7 +147,7 @@ bfdev_find_prev_bit(const unsigned long *addr,
139147

140148
if (!bfdev_const_small_nbits(bits)) {
141149
return bfdev_comp_find_prev_bit(addr, BFDEV_NULL,
142-
bits, offset, 0UL, bfdev_false);
150+
bits, offset, BFDEV_ULONG_MIN, bfdev_false);
143151
}
144152

145153
if (bfdev_unlikely(offset >= bits))
@@ -154,7 +162,7 @@ bfdev_find_prev_bit(const unsigned long *addr,
154162
#endif
155163

156164
/**
157-
* bfdev_find_next_bit() - find next zero in a region.
165+
* bfdev_find_next_zero() - find next zero in a region.
158166
* @block: the block to find.
159167
* @bits: number of bits in the block.
160168
* @offset: the bitnumber to start searching at.
@@ -171,7 +179,7 @@ bfdev_find_next_zero(const unsigned long *addr,
171179

172180
if (!bfdev_const_small_nbits(bits)) {
173181
return bfdev_comp_find_next_bit(addr, BFDEV_NULL,
174-
bits, offset, ~0UL, bfdev_false);
182+
bits, offset, BFDEV_ULONG_MAX, bfdev_false);
175183
}
176184

177185
if (bfdev_unlikely(offset >= bits))
@@ -194,7 +202,7 @@ bfdev_find_prev_zero(const unsigned long *addr,
194202

195203
if (!bfdev_const_small_nbits(bits)) {
196204
return bfdev_comp_find_prev_bit(addr, BFDEV_NULL,
197-
bits, offset, ~0UL, bfdev_false);
205+
bits, offset, BFDEV_ULONG_MAX, bfdev_false);
198206
}
199207

200208
if (bfdev_unlikely(offset >= bits))
@@ -230,7 +238,7 @@ bfdev_find_next_and_bit(const unsigned long *addr1, const unsigned long *addr2,
230238

231239
if (!bfdev_const_small_nbits(bits)) {
232240
return bfdev_comp_find_next_bit(addr1, addr2,
233-
bits, offset, 0UL, bfdev_false);
241+
bits, offset, BFDEV_ULONG_MIN, bfdev_false);
234242
}
235243

236244
value = *addr1 & *addr2 & BFDEV_BIT_RANGE(bits - 1, offset);
@@ -250,7 +258,7 @@ bfdev_find_prev_and_bit(const unsigned long *addr1, const unsigned long *addr2,
250258

251259
if (!bfdev_const_small_nbits(bits)) {
252260
return bfdev_comp_find_prev_bit(addr1, addr2,
253-
bits, offset, 0UL, bfdev_false);
261+
bits, offset, BFDEV_ULONG_MIN, bfdev_false);
254262
}
255263

256264
if (bfdev_unlikely(offset >= bits))

src/bitmap.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,15 @@ bfdev_bitmap_comp_clr(unsigned long *bitmap, unsigned int start,
343343
export unsigned long *
344344
bfdev_bitmap_alloc(const bfdev_alloc_t *alloc, unsigned int bits)
345345
{
346-
return bfdev_malloc_array(
347-
alloc, BFDEV_BITS_TO_LONG(bits), sizeof(unsigned long)
348-
);
346+
return bfdev_malloc_array(alloc, BFDEV_BITS_TO_LONG(bits),
347+
BFDEV_BYTES_PER_LONG);
349348
}
350349

351350
export unsigned long *
352351
bfdev_bitmap_zalloc(const bfdev_alloc_t *alloc, unsigned int bits)
353352
{
354-
return bfdev_zalloc_array(
355-
alloc, BFDEV_BITS_TO_LONG(bits), sizeof(unsigned long)
356-
);
353+
return bfdev_zalloc_array(alloc, BFDEV_BITS_TO_LONG(bits),
354+
BFDEV_BYTES_PER_LONG);
357355
}
358356

359357
export void

0 commit comments

Comments
 (0)