* [PATCH] usb: dwc3: core: Fix compile warning on s390 gcc in dwc3_get_phy call
@ 2024-04-26 5:05 Krishna Kurapati
2024-04-26 9:46 ` Johan Hovold
0 siblings, 1 reply; 2+ messages in thread
From: Krishna Kurapati @ 2024-04-26 5:05 UTC (permalink / raw)
To: Greg Kroah-Hartman, Thinh Nguyen
Cc: linux-usb, linux-kernel, quic_ppratap, quic_jackp,
Krishna Kurapati, Johan Hovold, kernel test robot
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@kernel.org>
Fixes: 30a46746ca5a ("usb: dwc3: core: Refactor PHY logic to support Multiport Controller")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202404241215.Mib19Cu7-lkp@intel.com/
Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
---
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;
if (node) {
dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
@@ -1479,7 +1479,7 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
if (dwc->num_usb2_ports == 1)
snprintf(phy_name, sizeof(phy_name), "usb2-phy");
else
- snprintf(phy_name, sizeof(phy_name), "usb2-%d", i);
+ snprintf(phy_name, sizeof(phy_name), "usb2-%u", i);
dwc->usb2_generic_phy[i] = devm_phy_get(dev, phy_name);
if (IS_ERR(dwc->usb2_generic_phy[i])) {
@@ -1496,7 +1496,7 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
if (dwc->num_usb3_ports == 1)
snprintf(phy_name, sizeof(phy_name), "usb3-phy");
else
- snprintf(phy_name, sizeof(phy_name), "usb3-%d", i);
+ snprintf(phy_name, sizeof(phy_name), "usb3-%u", i);
dwc->usb3_generic_phy[i] = devm_phy_get(dev, phy_name);
if (IS_ERR(dwc->usb3_generic_phy[i])) {
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] usb: dwc3: core: Fix compile warning on s390 gcc in dwc3_get_phy call
2024-04-26 5:05 [PATCH] usb: dwc3: core: Fix compile warning on s390 gcc in dwc3_get_phy call Krishna Kurapati
@ 2024-04-26 9:46 ` Johan Hovold
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2024-04-26 9:46 UTC (permalink / raw)
To: Krishna Kurapati
Cc: Greg Kroah-Hartman, Thinh Nguyen, linux-usb, linux-kernel,
quic_ppratap, quic_jackp, kernel test robot
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@kernel.org>
> Fixes: 30a46746ca5a ("usb: dwc3: core: Refactor PHY logic to support Multiport Controller")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202404241215.Mib19Cu7-lkp@intel.com/
> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
> ---
> 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@kernel.org>
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-26 9:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-26 5:05 [PATCH] usb: dwc3: core: Fix compile warning on s390 gcc in dwc3_get_phy call Krishna Kurapati
2024-04-26 9:46 ` Johan Hovold
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.