Re: [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison

From: Geert Uytterhoeven
Date: Wed Mar 24 2021 - 05:50:17 EST


Hi Gustavo,

On Thu, Oct 11, 2018 at 10:42 PM Gustavo A. R. Silva
<gustavo@xxxxxxxxxxxxxx> wrote:
> There is no need to compare ipctl->mdio_func[mdio] with => 0, because
> such comparison is always true. Notice that *mdio_func* is of type
> u32 (32 bits, unsigned).
>
> Fix this by removing such comparison.
>
> Addresses-Coverity-ID: 1474166 ("Unsigned compared against 0")
> Signed-off-by: Gustavo A. R. Silva <gustavo@xxxxxxxxxxxxxx>

Thanks for your patch, which I somehow missed to review.
Sorry for that.

> --- a/drivers/pinctrl/pinctrl-rzn1.c
> +++ b/drivers/pinctrl/pinctrl-rzn1.c
> @@ -195,7 +195,7 @@ static void rzn1_hw_set_lock(struct rzn1_pinctrl *ipctl, u8 lock, u8 value)
> static void rzn1_pinctrl_mdio_select(struct rzn1_pinctrl *ipctl, int mdio,
> u32 func)
> {
> - if (ipctl->mdio_func[mdio] >= 0 && ipctl->mdio_func[mdio] != func)
> + if (ipctl->mdio_func[mdio] != func)

Note that mdio_func is initialized to -1, hence the check.
But the check indeed didn't work this way, so mdio_func was changed
later to int in commit 8deaaa46d2de91e3 ("pinctrl: rzn1: Fix check for
used MDIO bus").

> dev_warn(ipctl->dev, "conflicting setting for mdio%d!\n", mdio);
> ipctl->mdio_func[mdio] = func;

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds