Skip to content

Commit c0e2b25

Browse files
fdmananakdave
authored andcommitted
btrfs: make extent_buffer_test_bit() return a boolean instead
All the callers want is to determine if a bit is set and all of them call the function and do a double negation (!!) on its result to get a boolean. So change it to return a boolean and simplify callers. Reviewed-by: Boris Burkov <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b96ceab commit c0e2b25

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

fs/btrfs/extent_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4107,8 +4107,8 @@ static inline void eb_bitmap_offset(const struct extent_buffer *eb,
41074107
* @start: offset of the bitmap item in the extent buffer
41084108
* @nr: bit number to test
41094109
*/
4110-
int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
4111-
unsigned long nr)
4110+
bool extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
4111+
unsigned long nr)
41124112
{
41134113
unsigned long i;
41144114
size_t offset;

fs/btrfs/extent_io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ void memmove_extent_buffer(const struct extent_buffer *dst,
345345
unsigned long len);
346346
void memzero_extent_buffer(const struct extent_buffer *eb, unsigned long start,
347347
unsigned long len);
348-
int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
349-
unsigned long pos);
348+
bool extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
349+
unsigned long pos);
350350
void extent_buffer_bitmap_set(const struct extent_buffer *eb, unsigned long start,
351351
unsigned long pos, unsigned long len);
352352
void extent_buffer_bitmap_clear(const struct extent_buffer *eb,

fs/btrfs/free-space-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ int free_space_test_bit(struct btrfs_block_group *block_group,
532532
ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
533533
i = div_u64(offset - found_start,
534534
block_group->fs_info->sectorsize);
535-
return !!extent_buffer_test_bit(leaf, ptr, i);
535+
return extent_buffer_test_bit(leaf, ptr, i);
536536
}
537537

538538
static void free_space_set_bits(struct btrfs_trans_handle *trans,

fs/btrfs/tests/extent-io-tests.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,11 @@ static int check_eb_bitmap(unsigned long *bitmap, struct extent_buffer *eb)
344344
unsigned long i;
345345

346346
for (i = 0; i < eb->len * BITS_PER_BYTE; i++) {
347-
int bit, bit1;
347+
bool bit_set, bit1_set;
348348

349-
bit = !!test_bit(i, bitmap);
350-
bit1 = !!extent_buffer_test_bit(eb, 0, i);
351-
if (bit1 != bit) {
349+
bit_set = test_bit(i, bitmap);
350+
bit1_set = extent_buffer_test_bit(eb, 0, i);
351+
if (bit1_set != bit_set) {
352352
u8 has;
353353
u8 expect;
354354

@@ -361,9 +361,9 @@ static int check_eb_bitmap(unsigned long *bitmap, struct extent_buffer *eb)
361361
return -EINVAL;
362362
}
363363

364-
bit1 = !!extent_buffer_test_bit(eb, i / BITS_PER_BYTE,
365-
i % BITS_PER_BYTE);
366-
if (bit1 != bit) {
364+
bit1_set = extent_buffer_test_bit(eb, i / BITS_PER_BYTE,
365+
i % BITS_PER_BYTE);
366+
if (bit1_set != bit_set) {
367367
u8 has;
368368
u8 expect;
369369

0 commit comments

Comments
 (0)