Skip to contentSkip to conversation

cpufreq: governor: Use sysfs_emit in sysfs show functions

PATCH Applied Thorsten Blum 3 participants 3 messages Feb 23 – Mar 6 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/cpufreq/cpufreq_governor.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq_governor.h +3 -2
index 168c23fd7fca..732fd4d1a803 100644
@@ -21,6 +21,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/sysfs.h>
 
 /* Ondemand Sampling types */
 enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE};
@@ -57,7 +58,7 @@ static ssize_t file_name##_show						\
 {									\
 	struct dbs_data *dbs_data = to_dbs_data(attr_set);		\
 	struct _gov##_dbs_tuners *tuners = dbs_data->tuners;		\
-	return sprintf(buf, "%u\n", tuners->file_name);			\
+	return sysfs_emit(buf, "%u\n", tuners->file_name);		\
 }
 
 #define gov_show_one_common(file_name)					\
@@ -65,7 +66,7 @@ static ssize_t file_name##_show						\
 (struct gov_attr_set *attr_set, char *buf)				\
 {									\
 	struct dbs_data *dbs_data = to_dbs_data(attr_set);		\
-	return sprintf(buf, "%u\n", dbs_data->file_name);		\
+	return sysfs_emit(buf, "%u\n", dbs_data->file_name);		\
 }
 
 #define gov_attr_ro(_name)						\
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Thorsten Blum

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.

---
 drivers/cpufreq/cpufreq_governor.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
viresh
maintainer Applied
#2 lore raw
Quoted 6 lines · Viresh Kumar
Quoted 4 lines · Thorsten Blum

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.

Quoted 6 lines
Quoted 4 lines
---
 drivers/cpufreq/cpufreq_governor.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Applied as 7.1 material, thanks!