drivers/hwmon/coretemp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Replace sprintf() with sysfs_emit() in sysfs show functions. sysfs_emit()
is preferred for formatting sysfs output because it provides safer bounds
checking. No functional changes.
Signed-off-by: Dongyang Jin <jindongyang@kylinos.cn>
---
drivers/hwmon/coretemp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 02b4e46d965b..074e46624701 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -346,9 +346,9 @@ static ssize_t show_label(struct device *dev,
struct temp_data *tdata = container_of(devattr, struct temp_data, sd_attrs[ATTR_LABEL]);
if (is_pkg_temp_data(tdata))
- return sprintf(buf, "Package id %u\n", pdata->pkg_id);
+ return sysfs_emit(buf, "Package id %u\n", pdata->pkg_id);
- return sprintf(buf, "Core %u\n", tdata->cpu_core_id);
+ return sysfs_emit(buf, "Core %u\n", tdata->cpu_core_id);
}
static ssize_t show_crit_alarm(struct device *dev,
@@ -362,7 +362,7 @@ static ssize_t show_crit_alarm(struct device *dev,
rdmsr_on_cpu(tdata->cpu, tdata->status_reg, &eax, &edx);
mutex_unlock(&tdata->update_lock);
- return sprintf(buf, "%d\n", (eax >> 5) & 1);
+ return sysfs_emit(buf, "%d\n", (eax >> 5) & 1);
}
static ssize_t show_tjmax(struct device *dev,
@@ -375,7 +375,7 @@ static ssize_t show_tjmax(struct device *dev,
tjmax = get_tjmax(tdata, dev);
mutex_unlock(&tdata->update_lock);
- return sprintf(buf, "%d\n", tjmax);
+ return sysfs_emit(buf, "%d\n", tjmax);
}
static ssize_t show_ttarget(struct device *dev,
@@ -390,7 +390,7 @@ static ssize_t show_ttarget(struct device *dev,
if (ttarget < 0)
return ttarget;
- return sprintf(buf, "%d\n", ttarget);
+ return sysfs_emit(buf, "%d\n", ttarget);
}
static ssize_t show_temp(struct device *dev,
@@ -417,7 +417,7 @@ static ssize_t show_temp(struct device *dev,
}
mutex_unlock(&tdata->update_lock);
- return sprintf(buf, "%d\n", tdata->temp);
+ return sysfs_emit(buf, "%d\n", tdata->temp);
}
static int create_core_attrs(struct temp_data *tdata, struct device *dev)
--
2.25.1
On 5/18/26 23:52, Dongyang Jin wrote: > Replace sprintf() with sysfs_emit() in sysfs show functions. sysfs_emit() > is preferred for formatting sysfs output because it provides safer bounds > checking. No functional changes. > > Signed-off-by: Dongyang Jin <jindongyang@kylinos.cn> I consider this a nuisance patch. Nothing is gained from it. Can people please stop sending such patches ? It gets annoying, and I don't have an endless amount of time to review it all. If you make a functional change or fix bugs, cleanups are welcome. Otherwise, I'll barely accept bare cleanup patches for drivers using the with_info API. Otherwise please leave old drivers alone. Thanks, Guenter
You are absolutely right, and I apologize for the noise. I misunderstood the scope of acceptable cleanups for legacy drivers. I will stop sending such patches and focus only on functional fixes or updates for drivers that specifically require them. Thank you for your time. Best regards, Dongyang Jin On 2026/5/19 23:16, Guenter Roeck wrote: > On 5/18/26 23:52, Dongyang Jin wrote: >> Replace sprintf() with sysfs_emit() in sysfs show functions. >> sysfs_emit() >> is preferred for formatting sysfs output because it provides safer >> bounds >> checking. No functional changes. >> >> Signed-off-by: Dongyang Jin <jindongyang@kylinos.cn> > > I consider this a nuisance patch. Nothing is gained from it. > Can people please stop sending such patches ? It gets annoying, > and I don't have an endless amount of time to review it all. > > If you make a functional change or fix bugs, cleanups are welcome. > Otherwise, I'll barely accept bare cleanup patches for drivers > using the with_info API. Otherwise please leave old drivers alone. > > Thanks, > Guenter
© 2016 - 2026 Red Hat, Inc.