Skip to contentSkip to conversation

bcache: work around a __bitwise to bool conversion sparse warning

PATCH Applied Christoph Hellwig 3 participants 3 messages Jun 28, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcache: work around a __bitwise to bool conversion sparse warning

Sparse is a bit dumb about bitwise operation on __bitwise types used in boolean contexts. Add a !! to explicitly propagate to boolean without a warning.

Fixes fcf865e357f8 ("block: convert features and flags to __bitwise types")
---
 drivers/md/bcache/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/bcache/super.c +2 -2
index 283b2511c6d21f..b5d6ef430b86fc 100644
@@ -1416,8 +1416,8 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
 	}
 
 	if (bdev_io_opt(dc->bdev))
-		dc->partial_stripes_expensive = q->limits.features &
-			BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE;
+		dc->partial_stripes_expensive = !!(q->limits.features &
+			BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE);
 
 	ret = bcache_device_init(&dc->disk, block_size,
 			 bdev_nr_sectors(dc->bdev) - dc->sb.data_offset,
Signature · 1 line
2.43.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Christoph Hellwig

Sparse is a bit dumb about bitwise operation on __bitwise types used in boolean contexts. Add a !! to explicitly propagate to boolean without a warning.

Fixes fcf865e357f8 ("block: convert features and flags to __bitwise types")
Quoted 22 lines
---
 drivers/md/bcache/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/bcache/super.c +2 -2
index 283b2511c6d21f..b5d6ef430b86fc 100644
@@ -1416,8 +1416,8 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
 	}
 
 	if (bdev_io_opt(dc->bdev))
-		dc->partial_stripes_expensive = q->limits.features &
-			BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE;
+		dc->partial_stripes_expensive = !!(q->limits.features &
+			BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE);
 
 	ret = bcache_device_init(&dc->disk, block_size,
 			 bdev_nr_sectors(dc->bdev) - dc->sb.data_offset,
Signature · 1 line
2.43.0
maintainer Applied
#2 lore raw
In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

Sparse is a bit dumb about bitwise operation on __bitwise types used in boolean contexts. Add a !! to explicitly propagate to boolean without a warning.

Applied, thanks!

[1/1] bcache: work around a __bitwise to bool conversion sparse warning

      commit: f1e46758e8b2b04c725ac706b5f455c0de0486a4

Best regards,

Signature · 1 line
Jens Axboe