Skip to content

Commit c7c2392

Browse files
committed
drivers/net/phy/mdio_bus: Fix gcc-10 -Wrestrict
Fixes drivers/net/phy/mdio_bus.c: In function 'phy_registers_show': drivers/net/phy/mdio_bus.c:665:3: warning: 'sprintf' argument 3 overlaps destination object 'buf' [-Wrestrict] error, forbidden warning:mdio_bus.c:665 665 | sprintf(buf, "%s%2d: 0x%x\n", buf, index, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 666 | phy_read(phydev, index)); | ~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/phy/mdio_bus.c:659:77: note: destination object referenced by 'restrict'-qualified argument 1 was declared here 659 | phy_registers_show(struct device *dev, struct device_attribute *attr, char *buf) | ~~~~~~^~~ Signed-off-by: Gleb Mazovetskiy <[email protected]>
1 parent e76f457 commit c7c2392

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/net/phy/mdio_bus.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,12 @@ phy_registers_show(struct device *dev, struct device_attribute *attr, char *buf)
661661
struct phy_device *phydev = to_phy_device(dev);
662662
int index;
663663

664-
for (index = 0; index < 32; index++)
665-
sprintf(buf, "%s%2d: 0x%x\n", buf, index,
664+
char tmp[50];
665+
for (index = 0; index < 32; index++) {
666+
snprintf(tmp, sizeof(tmp), "%2d: 0x%x\n", index,
666667
phy_read(phydev, index));
668+
strcat(buf, tmp);
669+
}
667670

668671
return strlen(buf);
669672
}

0 commit comments

Comments
 (0)