Re: [PATCH] [net-next] socket: fix unused-function warning
From: David Miller
Date: Wed Jan 08 2020 - 16:27:04 EST
From: Arnd Bergmann <arnd@xxxxxxxx>
Date: Tue, 7 Jan 2020 22:35:59 +0100
> When procfs is disabled, the fdinfo code causes a harmless
> warning:
>
> net/socket.c:1000:13: error: 'sock_show_fdinfo' defined but not used [-Werror=unused-function]
> static void sock_show_fdinfo(struct seq_file *m, struct file *f)
>
> Change the preprocessor conditional to a compiler conditional
> to avoid the warning and let the compiler throw away the
> function itself.
>
> Fixes: b4653342b151 ("net: Allow to show socket-specific information in /proc/[pid]/fdinfo/[fd]")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
This isn't the prettiest thing I've ever seen.
I really think it's nicer to just explicitly put ifdef's around the
forward declaration and the implementation of sock_show_fdinfo().
Alternatively, move the implementation up to the location of the
forward declaration and then you just need one new ifdef guard.