Re: [PATCH 13/18] serial: sc16is7xx: use in_range() for DT properties bound checks

From: Hugo Villeneuve
Date: Wed Dec 20 2023 - 11:27:21 EST


On Wed, 20 Dec 2023 17:54:07 +0200
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:

> On Tue, Dec 19, 2023 at 12:18:57PM -0500, Hugo Villeneuve wrote:
> > From: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
> >
> > Improve code readability and efficiency by using in_range() when checking
> > device tree properties bound.
>
> ...
>
> > count = device_property_count_u32(dev, "irda-mode-ports");
> > - if (count < 0 || count > SC16IS7XX_MAX_PORTS)
> > + if (!in_range(count, 0, SC16IS7XX_MAX_PORTS + 1))
> > return;
>
> Okay, looking at this, it becomes uglier than initial code,
> means my suggestion was not good. Please, drop this patch.

Ok, will drop it for V2.

Hugo Villeneuve