Re: [PATCH] usb: dwc3: core: Fix compile warning on s390 gcc in dwc3_get_phy call

From: Johan Hovold
Date: Fri Apr 26 2024 - 05:46:53 EST


On Fri, Apr 26, 2024 at 10:35:12AM +0530, Krishna Kurapati wrote:
> Recent commit introduced support for reading Multiport PHYs and
> while doing so iterated over an integer variable which runs from
> [0-254] in the worst case scenario. But S390 compiler treats it as a
> warning and complains that the integer write to string can go to 11
> characters. Fix this by modifying iterator variable to u8.
>
> Suggested-by: Johan Hovold <johan@xxxxxxxxxx>
> Fixes: 30a46746ca5a ("usb: dwc3: core: Refactor PHY logic to support Multiport Controller")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202404241215.Mib19Cu7-lkp@xxxxxxxxx/
> Signed-off-by: Krishna Kurapati <quic_kriskura@xxxxxxxxxxx>
> ---
> drivers/usb/dwc3/core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 4dc6fc79c6d9..719305ab86c0 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1449,7 +1449,7 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
> struct device_node *node = dev->of_node;
> char phy_name[9];
> int ret;
> - int i;
> + u8 i;

Perhaps unsigned int would have been better, but this should work too
(the broken compiler did get the upper bound right).

I assume you did not install a cross-compiler and tried to reproduce the
bogus warning?

In any case, if we want to suppress that bogus W=1 warning, this looks
good to me:

Reviewed-by: Johan Hovold <johan+linaro@xxxxxxxxxx>

Johan