linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Dennis Maisenbacher <Dennis.Maisenbacher@wdc.com>
Cc: linux-nvme@lists.infradead.org,
	Niklas Cassel <niklas.cassel@wdc.com>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvmet: fix mar and mor off-by-one errors
Date: Tue, 6 Sep 2022 06:45:49 +0200	[thread overview]
Message-ID: <20220906044549.GC32413@lst.de> (raw)
In-Reply-To: <20220905122116.2678206-1-Dennis.Maisenbacher@wdc.com>

On Mon, Sep 05, 2022 at 02:21:16PM +0200, Dennis Maisenbacher wrote:
> Cast the unsigned int values that are returned by bdev_max_open_zones and
> bdev_max_active_zones into u32 vales which need to be decremented as the
> returned values of the block layer helpers are not 0's based.
> The cast to u32 is necessary because the size of unsigned int is
> architecture dependent and a 0 reported by the block layer helpers
> indicates no limit, thus it needs to be converted to 0xffffffff which
> happens by underflowing the u32.

unsigned int (in Linux, not the C standard) is not architecture
dependent but always a 32-bit unsigned integer type.

But I'd much rather see an explicit check for 0 and conversion to
0xffffffff anyway.  Yes, unsigned integer underflow is well defined,
but having the explicit check explains much better to the read that it
is intentional.

Can you also add a Fixes tag, please?

  parent reply	other threads:[~2022-09-06  4:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 12:21 [PATCH] nvmet: fix mar and mor off-by-one errors Dennis Maisenbacher
2022-09-05 12:33 ` Niklas Cassel
2022-09-06  4:45 ` Christoph Hellwig [this message]
2022-09-06  7:36   ` Dennis Maisenbacher

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=20220906044549.GC32413@lst.de \
    --to=hch@lst.de \
    --cc=Dennis.Maisenbacher@wdc.com \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=niklas.cassel@wdc.com \
    --cc=sagi@grimberg.me \
    /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).