Skip to contentSkip to conversation

more int return value cleanup for blkdev.h helpers

PATCH In review Christoph Hellwig 5 participants 17 messages Nov 19, 2024 – Nov 20, 2024 Block layer

lore
Share & tools
lore
#0 lore raw

Hi Jens,

as John pointed out there are a bunch more helpers in blkdev.h that return int when the underlying value should be unsigned int. Thid series fixes those, and also switches those that return boolean values to bool and drop a duplicate prototype.

Diffstat:

 blkdev.h |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
#1 lore raw

PATCH 1/6 block: return unsigned int from bdev_io_opt

The underlying limit is defined as an unsigned int, so return that from bdev_io_opt as well.

---
 include/linux/blkdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blkdev.h +1 -1
index 195db38fda16..37439acfa34e 100644
@@ -1271,7 +1271,7 @@ static inline unsigned int queue_io_opt(const struct request_queue *q)
 	return q->limits.io_opt;
 }
 
-static inline int bdev_io_opt(struct block_device *bdev)
+static inline unsigned int bdev_io_opt(struct block_device *bdev)
 {
 	return queue_io_opt(bdev_get_queue(bdev));
 }
Signature · 1 line
2.45.2
#3 lore raw

PATCH 2/6 block: return unsigned int from queue_dma_alignment

In reply to Christoph Hellwig

The underlying limit is defined as an unsigned int, so return that from queue_dma_alignment as well.

---
 include/linux/blkdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blkdev.h +1 -1
index 37439acfa34e..d1a6f4bc4a1c 100644
@@ -1417,7 +1417,7 @@ static inline bool bdev_zone_is_seq(struct block_device *bdev, sector_t sector)
 	return is_seq;
 }
 
-static inline int queue_dma_alignment(const struct request_queue *q)
+static inline unsigned int queue_dma_alignment(const struct request_queue *q)
 {
 	return q->limits.dma_alignment;
 }
Signature · 1 line
2.45.2
#5 lore raw

PATCH 3/6 block: return unsigned int from blk_lim_dma_alignment_and_pad

In reply to Christoph Hellwig

The underlying limits are defined as unsigned int, so return that from blk_lim_dma_alignment_and_pad as well.

---
 include/linux/blkdev.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/blkdev.h +2 -1
index d1a6f4bc4a1c..74e3c611a4f7 100644
@@ -1458,7 +1458,8 @@ static inline bool bdev_iter_is_aligned(struct block_device *bdev,
 				   bdev_logical_block_size(bdev) - 1);
 }
 
-static inline int blk_lim_dma_alignment_and_pad(struct queue_limits *lim)
+static inline unsigned int
+blk_lim_dma_alignment_and_pad(struct queue_limits *lim)
 {
 	return lim->dma_alignment | lim->dma_pad_mask;
 }
Signature · 1 line
2.45.2
#7 lore raw

PATCH 4/6 block: return bool from blk_rq_aligned

In reply to Christoph Hellwig

blk_rq_aligned returns a boolean condition, don't mascquerade it as int.

---
 include/linux/blkdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blkdev.h +1 -1
index 74e3c611a4f7..e4fc967e8cb9 100644
@@ -1464,7 +1464,7 @@ blk_lim_dma_alignment_and_pad(struct queue_limits *lim)
 	return lim->dma_alignment | lim->dma_pad_mask;
 }
 
-static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
+static inline bool blk_rq_aligned(struct request_queue *q, unsigned long addr,
 				 unsigned int len)
 {
 	unsigned int alignment = blk_lim_dma_alignment_and_pad(&q->limits);
Signature · 1 line
2.45.2
Reviewed-by on v1 4/6
#8 lore raw

Re: [PATCH 4/6] block: return bool from blk_rq_aligned

Quoted 1 line · Christoph Hellwig

blk_rq_aligned returns a boolean condition, don't mascquerade it as int.

I think that the spelling is masquerade. Well according to spellcheck...

Quoted 2 lines
Quoted 17 lines
---
  include/linux/blkdev.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blkdev.h +1 -1
index 74e3c611a4f7..e4fc967e8cb9 100644
@@ -1464,7 +1464,7 @@ blk_lim_dma_alignment_and_pad(struct queue_limits *lim)
  	return lim->dma_alignment | lim->dma_pad_mask;
  }
 
-static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
+static inline bool blk_rq_aligned(struct request_queue *q, unsigned long addr,
  				 unsigned int len)
  {
  	unsigned int alignment = blk_lim_dma_alignment_and_pad(&q->limits);
#9 lore raw

Re: [PATCH 4/6] block: return bool from blk_rq_aligned

Quoted 4 lines · John Garry
Quoted 1 line · Christoph Hellwig

blk_rq_aligned returns a boolean condition, don't mascquerade it as int.

I think that the spelling is masquerade. Well according to spellcheck...

Hmm, I thought I had fixed that up because the spellchecker noticed it, but I guess I fumbled that up.

#10 lore raw

PATCH 5/6 block: remove a duplicate definition for bdev_read_only

In reply to Christoph Hellwig

bdev_read_only is already defined as an inline function in blkdev.h.

---
 include/linux/blkdev.h | 1 -
 1 file changed, 1 deletion(-)
include/linux/blkdev.h +0 -1
index e4fc967e8cb9..957767c0cafd 100644
@@ -1582,7 +1582,6 @@ static inline void bio_end_io_acct(struct bio *bio, unsigned long start_time)
 	return bio_end_io_acct_remapped(bio, start_time, bio->bi_bdev);
 }
 
-int bdev_read_only(struct block_device *bdev);
 int set_blocksize(struct file *file, int size);
 
 int lookup_bdev(const char *pathname, dev_t *dev);
Signature · 1 line
2.45.2
#12 lore raw

PATCH 6/6 block: return bool from get_disk_ro and bdev_read_only

In reply to Christoph Hellwig

get_disk_ro and bdev_read_only return boolean conditions, don't masquerade them as int.

---
 include/linux/blkdev.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/blkdev.h +2 -2
index 957767c0cafd..f2c0868544a3 100644
@@ -775,13 +775,13 @@ static inline void bdev_clear_flag(struct block_device *bdev, unsigned flag)
 	atomic_andnot(flag, &bdev->__bd_flags);
 }
 
-static inline int get_disk_ro(struct gendisk *disk)
+static inline bool get_disk_ro(struct gendisk *disk)
 {
 	return bdev_test_flag(disk->part0, BD_READ_ONLY) ||
 		test_bit(GD_READ_ONLY, &disk->state);
 }
 
-static inline int bdev_read_only(struct block_device *bdev)
+static inline bool bdev_read_only(struct block_device *bdev)
 {
 	return bdev_test_flag(bdev, BD_READ_ONLY) || get_disk_ro(bdev->bd_disk);
 }
Signature · 1 line
2.45.2
maintainer Applied
#16 lore raw
In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig

as John pointed out there are a bunch more helpers in blkdev.h that return int when the underlying value should be unsigned int. Thid series fixes those, and also switches those that return boolean values to bool and drop a duplicate prototype.

Diffstat:

 blkdev.h |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

[...]

Applied, thanks!

[1/6] block: return unsigned int from bdev_io_opt

      commit: 5a9d1b83e5334915c651604648c20a9fc64d47a3
[2/6] block: return unsigned int from queue_dma_alignment
      commit: ed5db174cf39374215934f21b04639a7a1513023
[3/6] block: return unsigned int from blk_lim_dma_alignment_and_pad
      commit: e769489a54401d0c89555f7ad8672038b5c2b767
[4/6] block: return bool from blk_rq_aligned
      commit: da77d9b23700708d0d22a4407d32a8755a3596e8
[5/6] block: remove a duplicate definition for bdev_read_only
      commit: e888810bc4f471f85989a0991aff28d2ac9f783b
[6/6] block: return bool from get_disk_ro and bdev_read_only
      commit: 766a71ef65bb217ed8bf1c068ac14c7d3c15d487

Best regards,

Signature · 1 line
Jens Axboe