Skip to content

Commit 022eec2

Browse files
tobluxrafaeljw
authored andcommitted
cpufreq: governor: Use sysfs_emit() in sysfs show functions
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: Thorsten Blum <thorsten.blum@linux.dev> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> [ rjw: Subject tweak ] Link: https://patch.msgid.link/20260223210351.344388-2-thorsten.blum@linux.dev Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 6acae3c commit 022eec2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/cpufreq/cpufreq_governor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/kernel_stat.h>
2222
#include <linux/module.h>
2323
#include <linux/mutex.h>
24+
#include <linux/sysfs.h>
2425

2526
/* Ondemand Sampling types */
2627
enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE};
@@ -57,15 +58,15 @@ static ssize_t file_name##_show \
5758
{ \
5859
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
5960
struct _gov##_dbs_tuners *tuners = dbs_data->tuners; \
60-
return sprintf(buf, "%u\n", tuners->file_name); \
61+
return sysfs_emit(buf, "%u\n", tuners->file_name); \
6162
}
6263

6364
#define gov_show_one_common(file_name) \
6465
static ssize_t file_name##_show \
6566
(struct gov_attr_set *attr_set, char *buf) \
6667
{ \
6768
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
68-
return sprintf(buf, "%u\n", dbs_data->file_name); \
69+
return sysfs_emit(buf, "%u\n", dbs_data->file_name); \
6970
}
7071

7172
#define gov_attr_ro(_name) \

0 commit comments

Comments
 (0)