Skip to contentSkip to conversation

btrfs: use common helper instead of open coding a bit test

PATCH In review David Sterba 2 participants 2 messages Sep 21, 2018 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

PATCH 1/1 btrfs: use common helper instead of open coding a bit test

The helper does the same math and we take care about the special case when flags is 0 too.

---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
index 909c578506ee..26eb388db343 100644
@@ -3691,7 +3691,7 @@ static int alloc_profile_is_valid(u64 flags, int extended)
 		return !extended; /* "0" is valid for usual profiles */
 
 	/* true if exactly one bit set */
-	return (flags & (flags - 1)) == 0;
+	return is_power_of_2(flags);
 }
 
 static inline int balance_need_close(struct btrfs_fs_info *fs_info)
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · David Sterba

The helper does the same math and we take care about the special case when flags is 0 too.

Quoted 18 lines
---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
index 909c578506ee..26eb388db343 100644
@@ -3691,7 +3691,7 @@ static int alloc_profile_is_valid(u64 flags, int extended)
 		return !extended; /* "0" is valid for usual profiles */
 
 	/* true if exactly one bit set */
-	return (flags & (flags - 1)) == 0;
+	return is_power_of_2(flags);
 }
 
 static inline int balance_need_close(struct btrfs_fs_info *fs_info)