linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH sysctl-next] reboot: Fix build warning without CONFIG_SYSFS
@ 2022-04-27 12:54 YueHaibing
  2022-05-04 20:59 ` Luis Chamberlain
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2022-04-27 12:54 UTC (permalink / raw)
  To: yuehaibing, mcgrof, tangmeng; +Cc: linux-kernel

If CONFIG_SYSFS 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.

Fixes: 06d177662fb8 ("kernel/reboot: move reboot sysctls to its own file")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 kernel/reboot.c | 54 ++++++++++++++++++++++++-------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/kernel/reboot.c b/kernel/reboot.c
index ed4e6dfb7d44..ecbf09ea03c5 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -421,33 +421,6 @@ void ctrl_alt_del(void)
 static char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff";
 static const char reboot_cmd[] = "/sbin/reboot";
 
-#ifdef CONFIG_SYSCTL
-static struct ctl_table kern_reboot_table[] = {
-	{
-		.procname       = "poweroff_cmd",
-		.data           = &poweroff_cmd,
-		.maxlen         = POWEROFF_CMD_PATH_LEN,
-		.mode           = 0644,
-		.proc_handler   = proc_dostring,
-	},
-	{
-		.procname       = "ctrl-alt-del",
-		.data           = &C_A_D,
-		.maxlen         = sizeof(int),
-		.mode           = 0644,
-		.proc_handler   = proc_dointvec,
-	},
-	{ }
-};
-
-static void __init kernel_reboot_sysctls_init(void)
-{
-	register_sysctl_init("kernel", kern_reboot_table);
-}
-#else
-#define kernel_reboot_sysctls_init() do { } while (0)
-#endif /* CONFIG_SYSCTL */
-
 static int run_cmd(const char *cmd)
 {
 	char **argv;
@@ -895,6 +868,33 @@ static struct attribute *reboot_attrs[] = {
 	NULL,
 };
 
+#ifdef CONFIG_SYSCTL
+static struct ctl_table kern_reboot_table[] = {
+	{
+		.procname       = "poweroff_cmd",
+		.data           = &poweroff_cmd,
+		.maxlen         = POWEROFF_CMD_PATH_LEN,
+		.mode           = 0644,
+		.proc_handler   = proc_dostring,
+	},
+	{
+		.procname       = "ctrl-alt-del",
+		.data           = &C_A_D,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = proc_dointvec,
+	},
+	{ }
+};
+
+static void __init kernel_reboot_sysctls_init(void)
+{
+	register_sysctl_init("kernel", kern_reboot_table);
+}
+#else
+#define kernel_reboot_sysctls_init() do { } while (0)
+#endif /* CONFIG_SYSCTL */
+
 static const struct attribute_group reboot_attr_group = {
 	.attrs = reboot_attrs,
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH sysctl-next] reboot: Fix build warning without CONFIG_SYSFS
  2022-04-27 12:54 [PATCH sysctl-next] reboot: Fix build warning without CONFIG_SYSFS YueHaibing
@ 2022-05-04 20:59 ` Luis Chamberlain
  0 siblings, 0 replies; 2+ messages in thread
From: Luis Chamberlain @ 2022-05-04 20:59 UTC (permalink / raw)
  To: YueHaibing; +Cc: tangmeng, linux-kernel

On Wed, Apr 27, 2022 at 08:54:01PM +0800, YueHaibing wrote:
> If CONFIG_SYSFS 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.
> 
> Fixes: 06d177662fb8 ("kernel/reboot: move reboot sysctls to its own file")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Thanks! Merged and pushed onto sysctl-testing. If there are no issues I'll move
it to sysctl-next.

  Luis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-04 20:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 12:54 [PATCH sysctl-next] reboot: Fix build warning without CONFIG_SYSFS YueHaibing
2022-05-04 20:59 ` Luis Chamberlain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).