]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: make extent_buffer_test_bit() return a boolean instead
authorFilipe Manana <fdmanana@suse.com>
Wed, 11 Jun 2025 11:25:48 +0000 (12:25 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:58:02 +0000 (23:58 +0200)
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 <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/free-space-tree.c
fs/btrfs/tests/extent-io-tests.c

index 3628bd504e37357bd04fbb882b4ebc4f35f77574..1a56fb258204dc9f80a390b995762456800667f6 100644 (file)
@@ -4106,8 +4106,8 @@ static inline void eb_bitmap_offset(const struct extent_buffer *eb,
  * @start:  offset of the bitmap item in the extent buffer
  * @nr:     bit number to test
  */
-int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
-                          unsigned long nr)
+bool extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
+                           unsigned long nr)
 {
        unsigned long i;
        size_t offset;
index 65bb87f1dce61e859cdb8248f6bf28c71673501c..61130786b9a3ad1ec481396575ee4f75bd843780 100644 (file)
@@ -345,8 +345,8 @@ void memmove_extent_buffer(const struct extent_buffer *dst,
                           unsigned long len);
 void memzero_extent_buffer(const struct extent_buffer *eb, unsigned long start,
                           unsigned long len);
-int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
-                          unsigned long pos);
+bool extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
+                           unsigned long pos);
 void extent_buffer_bitmap_set(const struct extent_buffer *eb, unsigned long start,
                              unsigned long pos, unsigned long len);
 void extent_buffer_bitmap_clear(const struct extent_buffer *eb,
index 29fada10158cf21ff9aff5e53d4a793d52078aab..b24c23312892bf5771c3535ef2cb3f732d5b0fa6 100644 (file)
@@ -532,7 +532,7 @@ int free_space_test_bit(struct btrfs_block_group *block_group,
        ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
        i = div_u64(offset - found_start,
                    block_group->fs_info->sectorsize);
-       return !!extent_buffer_test_bit(leaf, ptr, i);
+       return extent_buffer_test_bit(leaf, ptr, i);
 }
 
 static void free_space_set_bits(struct btrfs_trans_handle *trans,
index 557d05220de16f1eb0c47252a6885d731b7b0fda..87f7437be022b8ef29b98f0a03afa6b3e3b5a075 100644 (file)
@@ -344,11 +344,11 @@ static int check_eb_bitmap(unsigned long *bitmap, struct extent_buffer *eb)
        unsigned long i;
 
        for (i = 0; i < eb->len * BITS_PER_BYTE; i++) {
-               int bit, bit1;
+               bool bit_set, bit1_set;
 
-               bit = !!test_bit(i, bitmap);
-               bit1 = !!extent_buffer_test_bit(eb, 0, i);
-               if (bit1 != bit) {
+               bit_set = test_bit(i, bitmap);
+               bit1_set = extent_buffer_test_bit(eb, 0, i);
+               if (bit1_set != bit_set) {
                        u8 has;
                        u8 expect;
 
@@ -361,9 +361,9 @@ static int check_eb_bitmap(unsigned long *bitmap, struct extent_buffer *eb)
                        return -EINVAL;
                }
 
-               bit1 = !!extent_buffer_test_bit(eb, i / BITS_PER_BYTE,
-                                               i % BITS_PER_BYTE);
-               if (bit1 != bit) {
+               bit1_set = extent_buffer_test_bit(eb, i / BITS_PER_BYTE,
+                                                 i % BITS_PER_BYTE);
+               if (bit1_set != bit_set) {
                        u8 has;
                        u8 expect;