diff mbox series

[net,v2,1/2] net: phy: Fix formatting specifier to avoid potential string cuts

Message ID 20250319105813.3102076-2-andriy.shevchenko@linux.intel.com
State New
Headers show
Series net: phy: Fix potential string cut when using PHY_ID_FMT | expand

Commit Message

Andy Shevchenko March 19, 2025, 10:54 a.m. UTC
The PHY_ID_FMT is defined with '%02x' which is _minumum_ digits
to be printed. This, in particular, may trigger GCC warning, when
the parameter for the above mentioned specifier is bigger than
a byte. Avoid this, by limiting the amount of digits to be printed
to two. This is okay as the PHY maximum address is 31 and it fits.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/phy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 19f076a71f94..3b18c241f33e 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -309,7 +309,7 @@  static inline long rgmii_clock(int speed)
 #define PHY_MAX_ADDR	32
 
 /* Used when trying to connect to a specific phy (mii bus id:phy device id) */
-#define PHY_ID_FMT "%s:%02x"
+#define PHY_ID_FMT "%s:%02hhx"
 
 #define MII_BUS_ID_SIZE	61