From nobody Sun May 10 17:53:34 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FA88C433F5 for ; Wed, 27 Apr 2022 12:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234960AbiD0M5g (ORCPT ); Wed, 27 Apr 2022 08:57:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234805AbiD0M53 (ORCPT ); Wed, 27 Apr 2022 08:57:29 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA79410AC for ; Wed, 27 Apr 2022 05:54:17 -0700 (PDT) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KpJVV2VnrzCsMX; Wed, 27 Apr 2022 20:49:38 +0800 (CST) Received: from localhost (10.174.179.215) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:54:11 +0800 From: YueHaibing To: , , CC: Subject: [PATCH sysctl-next] reboot: Fix build warning without CONFIG_SYSFS Date: Wed, 27 Apr 2022 20:54:01 +0800 Message-ID: <20220427125401.28868-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If CONFIG_SYSFS is n, build warn: kernel/reboot.c:443:20: error: =E2=80=98kernel_reboot_sysctls_init=E2=80=99= defined but not used [-Werror=3Dunused-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 --- 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] =3D "/sbin/poweroff"; static const char reboot_cmd[] =3D "/sbin/reboot"; =20 -#ifdef CONFIG_SYSCTL -static struct ctl_table kern_reboot_table[] =3D { - { - .procname =3D "poweroff_cmd", - .data =3D &poweroff_cmd, - .maxlen =3D POWEROFF_CMD_PATH_LEN, - .mode =3D 0644, - .proc_handler =3D proc_dostring, - }, - { - .procname =3D "ctrl-alt-del", - .data =3D &C_A_D, - .maxlen =3D sizeof(int), - .mode =3D 0644, - .proc_handler =3D 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[] =3D { NULL, }; =20 +#ifdef CONFIG_SYSCTL +static struct ctl_table kern_reboot_table[] =3D { + { + .procname =3D "poweroff_cmd", + .data =3D &poweroff_cmd, + .maxlen =3D POWEROFF_CMD_PATH_LEN, + .mode =3D 0644, + .proc_handler =3D proc_dostring, + }, + { + .procname =3D "ctrl-alt-del", + .data =3D &C_A_D, + .maxlen =3D sizeof(int), + .mode =3D 0644, + .proc_handler =3D 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 =3D { .attrs =3D reboot_attrs, }; --=20 2.17.1