public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: Reduce the scope of a variable in __blk_mq_update_nr_hw_queues()
@ 2025-06-26 21:22 Bart Van Assche
  2025-06-27  7:18 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2025-06-26 21:22 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Christoph Hellwig, Bart Van Assche

Improve code readability by reducing the scope of the variable 'i'.

This patch fixes the following W=2 compiler warning:

block/blk-mq.c:5037:8: error: declaration shadows a local variable [-Werror,-Wshadow]
 5037 |                         int i = prev_nr_hw_queues;
      |                             ^
block/blk-mq.c:4999:6: note: previous declaration is here
 4999 |         int i;
      |             ^

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/blk-mq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4806b867e37d..e4202d8f68f9 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4972,7 +4972,6 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
 	struct request_queue *q;
 	int prev_nr_hw_queues = set->nr_hw_queues;
 	unsigned int memflags;
-	int i;
 
 	lockdep_assert_held(&set->tag_list_lock);
 
@@ -5032,7 +5031,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
 	memalloc_noio_restore(memflags);
 
 	/* Free the excess tags when nr_hw_queues shrink. */
-	for (i = set->nr_hw_queues; i < prev_nr_hw_queues; i++)
+	for (int i = set->nr_hw_queues; i < prev_nr_hw_queues; i++)
 		__blk_mq_free_map_and_rqs(set, i);
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: Reduce the scope of a variable in __blk_mq_update_nr_hw_queues()
  2025-06-26 21:22 [PATCH] block: Reduce the scope of a variable in __blk_mq_update_nr_hw_queues() Bart Van Assche
@ 2025-06-27  7:18 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2025-06-27  7:18 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Christoph Hellwig

On Thu, Jun 26, 2025 at 02:22:01PM -0700, Bart Van Assche wrote:
> Improve code readability by reducing the scope of the variable 'i'.
> 
> This patch fixes the following W=2 compiler warning:
> 
> block/blk-mq.c:5037:8: error: declaration shadows a local variable [-Werror,-Wshadow]
>  5037 |                         int i = prev_nr_hw_queues;
>       |                             ^
> block/blk-mq.c:4999:6: note: previous declaration is here
>  4999 |         int i;

If we want to fix this renaming one variable is much better.

But Nilay is currently active with major changes to this area, let's
delay cosmetic fixes until that has landed.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-27  7:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 21:22 [PATCH] block: Reduce the scope of a variable in __blk_mq_update_nr_hw_queues() Bart Van Assche
2025-06-27  7:18 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox