All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: fix arg type in `blk_mq_update_nr_hw_queues`
Date: Tue, 09 Jun 2026 09:59:56 +0200	[thread overview]
Message-ID: <87qzmggn43.fsf@kernel.org> (raw)
In-Reply-To: <5353c4b0-fc3b-4fa7-bcd6-c8cc490699ea@acm.org>

"Bart Van Assche" <bvanassche@acm.org> writes:

> On 6/8/26 1:39 AM, Andreas Hindborg wrote:
>> The type of the argument `nr_hw_queues` in the function
>> `blk_mq_update_nr_hw_queues` is a signed integer. This is wrong,
>> considering the field `nr_hw_queues` of `struct blk_mq_tag_set` is
>> unsigned. Thus, change the type of the parameter to unsigned.
>
> Will there ever be storage devices that support more than 2**31 hardware
> queues? If not,

Probably not.

> I think the word "wrong" in the commit message is too
> strong.

Right, I understand. I can change the wording. I chose it because it
seems wrong to me to use a signed type for a value that logically should
never assume a negative value. If the negative value was used to carry
some kind of information, it would make sense, but that is not the case
here.

> If this patch does not change the behavior of the code for any practical
> use case that would be good to mention.

The patch does not change behavior of the code as long as no overflows
occur, and they are not likely to occur. I will be sure to add that to
the commit message.

I came across this while designing the Rust API for these functions.
Rust is kind of particular about integer types, so it gave me some
checks/casts on the Rust side that really should no be required. I was
thinking we might as well change the type on the C side to unsigned when
the data it carries really should be unsigned.

Best regards,
Andreas Hindborg



  reply	other threads:[~2026-06-09  8:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08  8:39 [PATCH] block: fix arg type in `blk_mq_update_nr_hw_queues` Andreas Hindborg
2026-06-08 15:50 ` Bart Van Assche
2026-06-09  7:59   ` Andreas Hindborg [this message]
2026-06-09 15:05     ` 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=87qzmggn43.fsf@kernel.org \
    --to=a.hindborg@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.