From: John Garry <john.g.garry@oracle.com>
To: Qianfeng Rong <rongqianfeng@vivo.com>,
Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: use int type to store negative value
Date: Tue, 2 Sep 2025 17:11:02 +0100 [thread overview]
Message-ID: <b6c44c7c-282f-4f1c-aeb4-af0b39bfae78@oracle.com> (raw)
In-Reply-To: <20250902130930.68317-1-rongqianfeng@vivo.com>
On 02/09/2025 14:09, Qianfeng Rong wrote:
maybe be more exact in the subject, like "block: use int to store
blk_stack_limits() return value"
> 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://urldefense.com/v3/__https://lore.kernel.org/all/x3wogjf6vgpkisdhg3abzrx7v7zktmdnfmqeih5kosszmagqfs@oh3qxrgzkikf/__;!!ACWV5N9M2RV99hQ!JfWLPo_X7bYZL3xujNcmSob_sFzfvnOmFwzTQ-buSgEyxB4Rx04CZsZmcwf8CSAME6ySlTkSsgsc2EWpNVX-LC_C$ #1
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: John Garry <john.g.garry@oracle.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);
>
next prev parent reply other threads:[~2025-09-02 16:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 13:09 [PATCH] block: use int type to store negative value Qianfeng Rong
2025-09-02 16:03 ` Bart Van Assche
2025-09-02 16:11 ` John Garry [this message]
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=b6c44c7c-282f-4f1c-aeb4-af0b39bfae78@oracle.com \
--to=john.g.garry@oracle.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).