]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal: intel: int340x: Replace sprintf() with sysfs_emit()
authorKaushlendra Kumar <kaushlendra.kumar@intel.com>
Thu, 30 Oct 2025 05:34:10 +0000 (11:04 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 12 Nov 2025 20:13:13 +0000 (21:13 +0100)
Replace sprintf() calls with sysfs_emit() in sysfs "show" functions to
follow current kernel coding standards.

sysfs_emit() is the preferred method for formatting sysfs output as it
provides better bounds checking and is more secure.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
[ rjw: Subject adjustments, changelog edits ]
Link: https://patch.msgid.link/20251030053410.311656-1-kaushlendra.kumar@intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/intel/int340x_thermal/int3400_thermal.c

index 128556632685c45cad5b970450e04b448eb1dd92..1aedc6709229a66b2412da0890b4acbb13b43d40 100644 (file)
@@ -114,7 +114,7 @@ static ssize_t available_uuids_show(struct device *dev,
        int length = 0;
 
        if (!priv->uuid_bitmap)
-               return sprintf(buf, "UNKNOWN\n");
+               return sysfs_emit(buf, "UNKNOWN\n");
 
        for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; i++) {
                if (priv->uuid_bitmap & (1 << i))
@@ -131,7 +131,7 @@ static ssize_t current_uuid_show(struct device *dev,
        int i, length = 0;
 
        if (priv->current_uuid_index >= 0)
-               return sprintf(buf, "%s\n",
+               return sysfs_emit(buf, "%s\n",
                               int3400_thermal_uuids[priv->current_uuid_index]);
 
        for (i = 0; i <= INT3400_THERMAL_CRITICAL; i++) {
@@ -142,7 +142,7 @@ static ssize_t current_uuid_show(struct device *dev,
        if (length)
                return length;
 
-       return sprintf(buf, "INVALID\n");
+       return sysfs_emit(buf, "INVALID\n");
 }
 
 static int int3400_thermal_run_osc(acpi_handle handle, char *uuid_str, int *enable)
@@ -342,7 +342,7 @@ static ssize_t odvp_show(struct device *dev, struct device_attribute *attr,
 
        odvp_attr = container_of(attr, struct odvp_attr, attr);
 
-       return sprintf(buf, "%d\n", odvp_attr->priv->odvp[odvp_attr->odvp]);
+       return sysfs_emit(buf, "%d\n", odvp_attr->priv->odvp[odvp_attr->odvp]);
 }
 
 static void cleanup_odvp(struct int3400_thermal_priv *priv)