Message ID | 20250319105813.3102076-2-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: phy: Fix potential string cut when using PHY_ID_FMT | expand |
On Wed, Mar 19, 2025 at 12:54:33PM +0200, Andy Shevchenko wrote: > 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. For the curious: additional reading in the commit 46d57a7a8e33 ("docs: printk-formats: Fix hex printing of signed values").
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
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(-)