[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Thu, 12 Dec 2019 07:16:07 -0800
From: Mike Travis <mike.travis@....com>
To: Christoph Hellwig <hch@...radead.org>,
Arnd Bergmann <arnd@...db.de>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, Steve Wahl <steve.wahl@....com>,
Dimitri Sivanich <dimitri.sivanich@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
"H. Peter Anvin" <hpa@...or.com>,
Hedi Berriche <hedi.berriche@....com>,
Justin Ernst <justin.ernst@....com>,
Peter Zijlstra <peterz@...radead.org>,
Russ Anderson <russ.anderson@....com>,
Anshuman Khandual <anshuman.khandual@....com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/platform/uv: avoid unused variable warning
On 12/12/2019 6:54 AM, Christoph Hellwig wrote:
> Instead of that maybe_unused mess please just use good old ifdefs.
>
>> if (hubless)
>> - proc_version_fops.open = proc_hubless_open;
>> + proc_create_single("hubless", 0, pde, proc_hubless_show);
>> else
>> - proc_version_fops.open = proc_hubbed_open;
>> + proc_create_single("hubbed", 0, pde, proc_hubbed_show);
>> }
>
> Or someone could figure out what happens if we turn the
> proc_create_single stub into an inline function instead of the
> define. That makes it used at a syntactic level, the big question is
> if the compiler is smart enough to optimize away the unused callback
> still.
>
Yes, if CONFIG_PROC_FS is undefined, then this whole section can be
removed since it's sole purpose is to set up the /proc/ interface.
Something like this should suffice:
> ---
> arch/x86/kernel/apic/x2apic_uv_x.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> --- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c
> +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c
> @@ -1533,6 +1533,7 @@ static void check_efi_reboot(void)
> reboot_type = BOOT_ACPI;
> }
>
> +#ifdef CONFIG_PROC_FS
> /* Setup user proc fs files */
> static int proc_hubbed_show(struct seq_file *file, void *data)
> {
> @@ -1595,6 +1596,14 @@ static __init void uv_setup_proc_files(i
> proc_version_fops.open = proc_hubbed_open;
> }
>
> +#else /* !CONFIG_PROC_FS */
> +
> +static __init void uv_setup_proc_files(int hubless)
> +{
> +}
> +
> +#endif /* !CONFIG_PROC_FS */
> +
> /* Initialize UV hubless systems */
> static __init int uv_system_init_hubless(void)
> {
Powered by blists - more mailing lists