[PATCH V2 03/12] nvmet: use consistent type with id->nlbaf

Keith Busch kbusch at kernel.org
Tue Sep 1 18:03:06 EDT 2020


On Tue, Sep 01, 2020 at 09:17:45PM +0000, Chaitanya Kulkarni wrote:
> On 9/1/20 08:56, Keith Busch wrote:
> > On Mon, Aug 31, 2020 at 03:26:58PM -0700, Chaitanya Kulkarni wrote:
> >> In function nvmet_passthru_override_id_ns() while iterating
> >> over namespace lba format loop variable is declared as int that is
> >> inconsistent with the id->nlbaf type which is u8.
> >>
> >> Make loop variable of the same type as id->nlbaf.
> > The loop is id->nlbaf + 1, so it'd overflow if the nlbaf value is the max
> > u8. Sure, it doesn't get that large today, but they're always trying to
> > make it bigger. And there's really nothing wrong with counting for loops
> > with 'int i' anyway.
> > 
> 
> In past when ppl run proprietary static checker it has generated
> warnings for such cases.

Sounds broken. Adding a constant coereces an int, so comparing with a
declared int should be what static analysis wants if they're being
pedantic about it.



More information about the Linux-nvme mailing list