From: Bart Van Assche <bvanassche@acm.org>
To: Qianfeng Rong <rongqianfeng@vivo.com>,
Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: Re: [PATCH] block: use int type to store negative value
Date: Tue, 2 Sep 2025 09:03:08 -0700 [thread overview]
Message-ID: <51d863a4-fe0a-4a08-a3a5-dd7b402ce824@acm.org> (raw)
In-Reply-To: <20250902130930.68317-1-rongqianfeng@vivo.com>
On 9/2/25 6:09 AM, Qianfeng Rong wrote:
> 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/ #1
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
> block/blk-settings.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index d6438e6c276d..693bc8d20acf 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -763,7 +763,8 @@ static void blk_stack_atomic_writes_limits(struct queue_limits *t,
> 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);
Has it been considered to add a Fixes tag, e.g. this tag?
Fixes: fe0b393f2c0a ("block: Correct handling of bottom device misaligment")
With or without that tag:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
next prev parent reply other threads:[~2025-09-02 16:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 13:09 Qianfeng Rong
2025-09-02 16:03 ` Bart Van Assche [this message]
2025-09-02 16:11 ` John Garry
2025-09-03 1:21 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51d863a4-fe0a-4a08-a3a5-dd7b402ce824@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=rongqianfeng@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®