Skip to contentSkip to conversation

staging: greybus: gbphy: use sysfs_emit() instead of sprintf()

PATCH In review Mohit Mishra 2 participants 2 messages Aug 8 – Sep 1

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: greybus: gbphy: use sysfs_emit() instead of sprintf()

protocol_id_show() uses sprintf() to format sysfs output into the page buffer. Convert it to sysfs_emit(), which is the preferred helper for sysfs show() callbacks as it enforces page boundary checks.

Similar conversions have already been made elsewhere in this subsystem (e.g. loopback.c, arche-platform.c).

---
 drivers/staging/greybus/gbphy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/gbphy.c +1 -1
index bdb0f5164a6f..bb9a5b538e6e 100644
@@ -31,7 +31,7 @@ static ssize_t protocol_id_show(struct device *dev,
 {
 	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
 
-	return sprintf(buf, "0x%02x\n", gbphy_dev->cport_desc->protocol_id);
+	return sysfs_emit(buf, "0x%02x\n", gbphy_dev->cport_desc->protocol_id);
 }
 static DEVICE_ATTR_RO(protocol_id);
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 28 lines · Mohit Mishra

protocol_id_show() uses sprintf() to format sysfs output into the page buffer. Convert it to sysfs_emit(), which is the preferred helper for sysfs show() callbacks as it enforces page boundary checks.

Similar conversions have already been made elsewhere in this subsystem (e.g. loopback.c, arche-platform.c).

---
 drivers/staging/greybus/gbphy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/gbphy.c +1 -1
index bdb0f5164a6f..bb9a5b538e6e 100644
@@ -31,7 +31,7 @@ static ssize_t protocol_id_show(struct device *dev,
 {
 	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
 
-	return sprintf(buf, "0x%02x\n", gbphy_dev->cport_desc->protocol_id);
+	return sysfs_emit(buf, "0x%02x\n", gbphy_dev->cport_desc->protocol_id);
 }
 static DEVICE_ATTR_RO(protocol_id);
 
Signature · 1 line
2.43.0

Please see the mailing list archives for why this type of patch keeps getting rejected.

sorry,

greg k-h