History

reboot: Fix build warning without CONFIG_SYSCTL

If CONFIG_SYSCTL is n, build warn: kernel/reboot.c:443:20: error: ‘kernel_reboot_sysctls_init’ defined but not used [-Werror=unused-function] static void __init kernel_reboot_sysctls_init(void) ^~~~~~~~~~~~~~~~~~~~~~~~~~ Move kernel_reboot_sysctls_init() to #ifdef block to fix this.

YueHaibing committed 4 years ago

Commit 764aaf41 parent a4672571 file · +27 −27Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/reboot.c+27−27
@@ -421,33 +421,6 @@ void ctrl_alt_del(void) · 420 unmodified lines
421421 static char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff";
422422 static const char reboot_cmd[] = "/sbin/reboot";
423423
424−#ifdef CONFIG_SYSCTL
425−static struct ctl_table kern_reboot_table[] = {
426− {
427− .procname = "poweroff_cmd",
428− .data = &poweroff_cmd,
429− .maxlen = POWEROFF_CMD_PATH_LEN,
430− .mode = 0644,
431− .proc_handler = proc_dostring,
432− },
433− {
434− .procname = "ctrl-alt-del",
435− .data = &C_A_D,
436− .maxlen = sizeof(int),
437− .mode = 0644,
438− .proc_handler = proc_dointvec,
439− },
440− { }
441−};
442−
443−static void __init kernel_reboot_sysctls_init(void)
444−{
445− register_sysctl_init("kernel", kern_reboot_table);
446−}
447−#else
448−#define kernel_reboot_sysctls_init() do { } while (0)
449−#endif /* CONFIG_SYSCTL */
450−
451424 static int run_cmd(const char *cmd)
452425 {
453426 char **argv;
@@ -895,6 +868,33 @@ static struct attribute *reboot_attrs[] = { · 441 unmodified lines
895868 NULL,
896869 };
897870
871+#ifdef CONFIG_SYSCTL
872+static struct ctl_table kern_reboot_table[] = {
873+ {
874+ .procname = "poweroff_cmd",
875+ .data = &poweroff_cmd,
876+ .maxlen = POWEROFF_CMD_PATH_LEN,
877+ .mode = 0644,
878+ .proc_handler = proc_dostring,
879+ },
880+ {
881+ .procname = "ctrl-alt-del",
882+ .data = &C_A_D,
883+ .maxlen = sizeof(int),
884+ .mode = 0644,
885+ .proc_handler = proc_dointvec,
886+ },
887+ { }
888+};
889+
890+static void __init kernel_reboot_sysctls_init(void)
891+{
892+ register_sysctl_init("kernel", kern_reboot_table);
893+}
894+#else
895+#define kernel_reboot_sysctls_init() do { } while (0)
896+#endif /* CONFIG_SYSCTL */
897+
898898 static const struct attribute_group reboot_attr_group = {
899899 .attrs = reboot_attrs,
900900 };