[PATCH 1/5] hwmon: tc74: use sysfs_emit() instead of sprintf()

Amay Agarwal posted 5 patches 8 hours ago
Only 2 patches received!
[PATCH 1/5] hwmon: tc74: use sysfs_emit() instead of sprintf()
Posted by Amay Agarwal 8 hours ago
Replacing sprintf() with sysfs_emit() for drivers/hwmon/tc74.c since it
is the preferred helper for formatting sysfs outputs and preventing
buffer overflows.

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 1/5] hwmon: tc74: use sysfs_emit() instead of sprintf()
Posted by Guenter Roeck 6 hours ago
On Tue, Mar 03, 2026 at 12:58:12AM +0530, Amay Agarwal wrote:
> Replacing sprintf() with sysfs_emit() for drivers/hwmon/tc74.c since it

That is not "imperative mood" as asked for in
Documentation/process/submitting-patches.rst.

While minor, I think it is especially important in patches like this one
which do not make functional changes.

On top of that, mentioning the driver name in the commit description
is pointless, and the subject fir hwmon patches should start with
"hwmon: (driver) ..."

Guenter

> is the preferred helper for formatting sysfs outputs and preventing
> buffer overflows.
> 
> 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);
>