Re: [PATCH] timer_list: Fix Wunused-const-variable
From: Nick Desaulniers
Date: Fri Jun 14 2019 - 17:29:15 EST
On Fri, Jun 14, 2019 at 11:16 AM 'Nathan Huckleberry' via Clang Built
Linux <clang-built-linux@xxxxxxxxxxxxxxxx> wrote:
>
> Clang produced the following warning when using allnoconfig
>
> kernel/time/timer_list.c:361:36: warning: unused variable
> 'timer_list_sops' [-Wunused-const-variable]
> static const struct seq_operations timer_list_sops = {
>
> Code reliant on CONFIG_PROC_FS is not in ifdef guard.
> Created ifdef guard around proc_fs specific code.
Specifically, it sounds like proc_create_seq_private expands to an
empty GNU C statement expression (not sure why not a `static inline`
function returning `NULL` but ok), so in that case, this object full
of function pointer, and its pointed to static functions (whose sole
references are this object) all become dead code.
>
> Cc: clang-built-linux@xxxxxxxxxxxxxxxx
> Link: https://github.com/ClangBuiltLinux/linux/issues/534
> Signed-off-by: Nathan Huckleberry <nhuck@xxxxxxxxxx>
Thanks for the patch, looks good! Make sure to include reported by
tags when someone else has reported an issue that you fix, in this
case:
Reported-by: kbuild test robot <lkp@xxxxxxxxx>
Link: https://groups.google.com/forum/#!topic/clang-built-linux/w27FQOTlb70
Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
> ---
> kernel/time/timer_list.c | 36 +++++++++++++++++++-----------------
> 1 file changed, 19 insertions(+), 17 deletions(-)
>
> diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
> index 98ba50dcb1b2..acb326f5f50a 100644
> --- a/kernel/time/timer_list.c
> +++ b/kernel/time/timer_list.c
> @@ -282,23 +282,6 @@ static inline void timer_list_header(struct seq_file *m, u64 now)
> SEQ_printf(m, "\n");
> }
>
> -static int timer_list_show(struct seq_file *m, void *v)
> -{
> - struct timer_list_iter *iter = v;
> -
> - if (iter->cpu == -1 && !iter->second_pass)
> - timer_list_header(m, iter->now);
> - else if (!iter->second_pass)
> - print_cpu(m, iter->cpu, iter->now);
> -#ifdef CONFIG_GENERIC_CLOCKEVENTS
> - else if (iter->cpu == -1 && iter->second_pass)
> - timer_list_show_tickdevices_header(m);
> - else
> - print_tickdevice(m, tick_get_device(iter->cpu), iter->cpu);
> -#endif
> - return 0;
> -}
> -
> void sysrq_timer_list_show(void)
> {
> u64 now = ktime_to_ns(ktime_get());
> @@ -317,6 +300,24 @@ void sysrq_timer_list_show(void)
> return;
> }
>
> +#ifdef CONFIG_PROC_FS
> +static int timer_list_show(struct seq_file *m, void *v)
> +{
> + struct timer_list_iter *iter = v;
> +
> + if (iter->cpu == -1 && !iter->second_pass)
> + timer_list_header(m, iter->now);
> + else if (!iter->second_pass)
> + print_cpu(m, iter->cpu, iter->now);
> +#ifdef CONFIG_GENERIC_CLOCKEVENTS
> + else if (iter->cpu == -1 && iter->second_pass)
> + timer_list_show_tickdevices_header(m);
> + else
> + print_tickdevice(m, tick_get_device(iter->cpu), iter->cpu);
> +#endif
> + return 0;
> +}
> +
> static void *move_iter(struct timer_list_iter *iter, loff_t offset)
> {
> for (; offset; offset--) {
> @@ -376,3 +377,4 @@ static int __init init_timer_list_procfs(void)
> return 0;
> }
> __initcall(init_timer_list_procfs);
> +#endif
> --
> 2.22.0.410.gd8fdbe21b5-goog
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@xxxxxxxxxxxxxxxxx
> To post to this group, send email to clang-built-linux@xxxxxxxxxxxxxxxxx
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20190614181604.112297-1-nhuck%40google.com.
> For more options, visit https://groups.google.com/d/optout.
--
Thanks,
~Nick Desaulniers