]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
block: use int to store blk_stack_limits() return value
authorQianfeng Rong <rongqianfeng@vivo.com>
Tue, 2 Sep 2025 13:09:30 +0000 (21:09 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 3 Sep 2025 01:19:25 +0000 (19:19 -0600)
Change the 'ret' variable in blk_stack_limits() from unsigned int to int,
as it needs to store negative value -1.

Storing the negative error codes in unsigned type, or performing equality
comparisons (e.g., ret == -1), doesn't cause an issue at runtime [1] but
can be confusing.  Additionally, assigning negative error codes to unsigned
type may trigger a GCC warning when the -Wsign-conversion flag is enabled.

No effect on runtime.

Link: https://lore.kernel.org/all/x3wogjf6vgpkisdhg3abzrx7v7zktmdnfmqeih5kosszmagqfs@oh3qxrgzkikf/
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Fixes: fe0b393f2c0a ("block: Correct handling of bottom device misaligment")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250902130930.68317-1-rongqianfeng@vivo.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-settings.c

index d6438e6c276dcc23ff42c2aadb3cb58d2c33e3ff..693bc8d20acf3cb4e9d5a791284e712d54bb468c 100644 (file)
@@ -763,7 +763,8 @@ unsupported:
 int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
                     sector_t start)
 {
-       unsigned int top, bottom, alignment, ret = 0;
+       unsigned int top, bottom, alignment;
+       int ret = 0;
 
        t->features |= (b->features & BLK_FEAT_INHERIT_MASK);