Skip to contentSkip to conversation

leds: led-class: Replace sprintf with sysfs_emit in sysfs show functions

PATCH Applied Thorsten Blum 2 participants 2 messages Nov 3, 2025 – Nov 13, 2025 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: led-class: Replace sprintf with sysfs_emit in sysfs show functions

Replace sprintf() with sysfs_emit() in sysfs show functions. sysfs_emit() is preferred to format sysfs output as it provides better bounds checking. No functional changes.

---
 drivers/leds/led-class.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/leds/led-class.c +3 -3
index f3faf37f9a08..885399ed0776 100644
@@ -38,7 +38,7 @@ static ssize_t brightness_show(struct device *dev,
 	brightness = led_cdev->brightness;
 	mutex_unlock(&led_cdev->led_access);
 
-	return sprintf(buf, "%u\n", brightness);
+	return sysfs_emit(buf, "%u\n", brightness);
 }
 
 static ssize_t brightness_store(struct device *dev,
@@ -80,7 +80,7 @@ static ssize_t max_brightness_show(struct device *dev,
 	max_brightness = led_cdev->max_brightness;
 	mutex_unlock(&led_cdev->led_access);
 
-	return sprintf(buf, "%u\n", max_brightness);
+	return sysfs_emit(buf, "%u\n", max_brightness);
 }
 static DEVICE_ATTR_RO(max_brightness);
 
@@ -122,7 +122,7 @@ static ssize_t brightness_hw_changed_show(struct device *dev,
 	if (led_cdev->brightness_hw_changed == -1)
 		return -ENODATA;
 
-	return sprintf(buf, "%u\n", led_cdev->brightness_hw_changed);
+	return sysfs_emit(buf, "%u\n", led_cdev->brightness_hw_changed);
 }
 
 static DEVICE_ATTR_RO(brightness_hw_changed);
Signature · 1 line
2.51.1
maintainer Applied
#1 lore raw

Re: (subset) [PATCH] leds: led-class: Replace sprintf with sysfs_emit in sysfs show functions

Quoted 5 lines · Thorsten Blum

Replace sprintf() with sysfs_emit() in sysfs show functions. sysfs_emit() is preferred to format sysfs output as it provides better bounds checking. No functional changes.

Applied, thanks!

[1/1] leds: led-class: Replace sprintf with sysfs_emit in sysfs show functions

      commit: 92f4b016dcb955cc0bb3942ac217cff6fe450a57

--
Lee Jones [李琼斯]