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 4BC9FC433EF for ; Wed, 27 Apr 2022 11:03:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbiD0LGK (ORCPT ); Wed, 27 Apr 2022 07:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232390AbiD0LFM (ORCPT ); Wed, 27 Apr 2022 07:05:12 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 792CE57128 for ; Wed, 27 Apr 2022 03:56:27 -0700 (PDT) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KpDDc70zXzhYqG; Wed, 27 Apr 2022 17:37:20 +0800 (CST) Received: from [10.174.179.215] (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 17:37:34 +0800 Subject: Re: [PATCH -next] reboot: Fix build warning without CONFIG_SYSFS To: Luis Chamberlain CC: , References: <20220407074807.1580-1-yuehaibing@huawei.com> <3d54a148-922d-3da4-b564-44996ca56241@huawei.com> From: YueHaibing Message-ID: Date: Wed, 27 Apr 2022 17:37:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 On 2022/4/27 10:26, Luis Chamberlain wrote: > Your subject says CONFIG_SYSFS but this is for CONFIG_SYSCTL right? > Can you fix and resubmit and based it on sysctl-next [0]? Sorry, will fix and resend. > > If I've missed any other patches please resubmit as well and use > the [PATCH sysctl-next] as prefix. > > [0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next > > Luis > > On Wed, Apr 27, 2022 at 09:56:35AM +0800, YueHaibing wrote: >> ping... >> >> On 2022/4/7 15:48, 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: 6e73c8344931 ("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] = "/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, >>> }; >>> > . >