lkml.org 
[lkml]   [2022]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] nvmet: fix mar and mor off-by-one errors
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?

\
 
 \ /
  Last update: 2022-09-06 06:47    [W:0.054 / U:21.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site