[PATCH v2 1/5] hwmon: (tc74) Replace sprintf() with sysfs_emit()

Amay Agarwal posted 5 patches 1 month ago
[PATCH v2 1/5] hwmon: (tc74) Replace sprintf() with sysfs_emit()
Posted by Amay Agarwal 1 month ago
Replace sprintf() with sysfs_emit() when writing to sysfs buffers.

sysfs_emit() performs proper bounds checking and is the preferred helper
for sysfs output.

No functional change intended

Signed-off-by: Amay Agarwal <tt@turingtested.xyz>
---
 drivers/hwmon/tc74.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/tc74.c b/drivers/hwmon/tc74.c
index 9984373a25fb..7fb7b50ad1ad 100644
--- a/drivers/hwmon/tc74.c
+++ b/drivers/hwmon/tc74.c
@@ -92,7 +92,7 @@ static ssize_t temp_input_show(struct device *dev,
 	if (ret)
 		return ret;
 
-	return sprintf(buf, "%d\n", data->temp_input * 1000);
+	return sysfs_emit(buf, "%d\n", data->temp_input * 1000);
 }
 static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0);
 
-- 
2.53.0
Re: [PATCH v2 1/5] hwmon: (tc74) Replace sprintf() with sysfs_emit()
Posted by Guenter Roeck 1 month ago
On Tue, Mar 03, 2026 at 08:54:52PM +0530, Amay Agarwal wrote:
> Replace sprintf() with sysfs_emit() when writing to sysfs buffers.
> 
> sysfs_emit() performs proper bounds checking and is the preferred helper
> for sysfs output.
> 
> No functional change intended
> 
> Signed-off-by: Amay Agarwal <tt@turingtested.xyz>

Applied.

Thanks,
Guenter