Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kernel/reboot: replace sprintf() with sysfs_emit()

As Documentation/filesystems/sysfs.rst suggested, show() should only use
sysfs_emit() or sysfs_emit_at() when formatting the value to be returned
to user space.

No functional change intended.

Link: https://lkml.kernel.org/r/20241105094941.33739-1-zhangguopeng@kylinos.cn
Signed-off-by: zhangguopeng <zhangguopeng@kylinos.cn>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Joel Granados <joel.granados@kernel.org>
Cc: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

zhangguopeng and committed by
Andrew Morton
45dac195 11131415

+4 -4
+4 -4
kernel/reboot.c
··· 1137 1137 val = REBOOT_UNDEFINED_STR; 1138 1138 } 1139 1139 1140 - return sprintf(buf, "%s\n", val); 1140 + return sysfs_emit(buf, "%s\n", val); 1141 1141 } 1142 1142 static ssize_t mode_store(struct kobject *kobj, struct kobj_attribute *attr, 1143 1143 const char *buf, size_t count) ··· 1167 1167 #ifdef CONFIG_X86 1168 1168 static ssize_t force_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 1169 1169 { 1170 - return sprintf(buf, "%d\n", reboot_force); 1170 + return sysfs_emit(buf, "%d\n", reboot_force); 1171 1171 } 1172 1172 static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr, 1173 1173 const char *buf, size_t count) ··· 1214 1214 val = REBOOT_UNDEFINED_STR; 1215 1215 } 1216 1216 1217 - return sprintf(buf, "%s\n", val); 1217 + return sysfs_emit(buf, "%s\n", val); 1218 1218 } 1219 1219 static ssize_t type_store(struct kobject *kobj, struct kobj_attribute *attr, 1220 1220 const char *buf, size_t count) ··· 1247 1247 #ifdef CONFIG_SMP 1248 1248 static ssize_t cpu_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 1249 1249 { 1250 - return sprintf(buf, "%d\n", reboot_cpu); 1250 + return sysfs_emit(buf, "%d\n", reboot_cpu); 1251 1251 } 1252 1252 static ssize_t cpu_store(struct kobject *kobj, struct kobj_attribute *attr, 1253 1253 const char *buf, size_t count)