mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] timer_list: Fix Wunused-const-variable
@ 2019-06-14 18:16 Nathan Huckleberry
  2019-06-14 21:24 ` Nick Desaulniers
  2019-06-23 10:22 ` [tip:timers/core] timer_list: Guard procfs specific code tip-bot for Nathan Huckleberry
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Huckleberry @ 2019-06-14 18:16 UTC (permalink / raw)
  To: john.stultz, tglx, sboyd
  Cc: linux-kernel, Nathan Huckleberry, clang-built-linux

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.

Cc: clang-built-linux@googlegroups.com
Link: https://github.com/ClangBuiltLinux/linux/issues/534
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] timer_list: Fix Wunused-const-variable
  2019-06-14 18:16 [PATCH] timer_list: Fix Wunused-const-variable Nathan Huckleberry
@ 2019-06-14 21:24 ` Nick Desaulniers
  2019-06-23 10:22 ` [tip:timers/core] timer_list: Guard procfs specific code tip-bot for Nathan Huckleberry
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2019-06-14 21:24 UTC (permalink / raw)
  To: Nathan Huckleberry
  Cc: John Stultz, Thomas Gleixner, sboyd, LKML, clang-built-linux

On Fri, Jun 14, 2019 at 11:16 AM 'Nathan Huckleberry' via Clang Built
Linux <clang-built-linux@googlegroups.com> 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@googlegroups.com
> Link: https://github.com/ClangBuiltLinux/linux/issues/534
> Signed-off-by: Nathan Huckleberry <nhuck@google.com>

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@intel.com>
Link: https://groups.google.com/forum/#!topic/clang-built-linux/w27FQOTlb70
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  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@googlegroups.com.
> To post to this group, send email to clang-built-linux@googlegroups.com.
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:timers/core] timer_list: Guard procfs specific code
  2019-06-14 18:16 [PATCH] timer_list: Fix Wunused-const-variable Nathan Huckleberry
  2019-06-14 21:24 ` Nick Desaulniers
@ 2019-06-23 10:22 ` tip-bot for Nathan Huckleberry
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Nathan Huckleberry @ 2019-06-23 10:22 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, tglx, mingo, ndesaulniers, hpa, nhuck

Commit-ID:  a9314773a91a1d3b36270085246a6715a326ff00
Gitweb:     https://git.kernel.org/tip/a9314773a91a1d3b36270085246a6715a326ff00
Author:     Nathan Huckleberry <nhuck@google.com>
AuthorDate: Fri, 14 Jun 2019 11:16:04 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 23 Jun 2019 00:08:52 +0200

timer_list: Guard procfs specific code

With CONFIG_PROC_FS=n the following warning is emitted:

kernel/time/timer_list.c:361:36: warning: unused variable
'timer_list_sops' [-Wunused-const-variable]
   static const struct seq_operations timer_list_sops = {

Add #ifdef guard around procfs specific code.

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: john.stultz@linaro.org
Cc: sboyd@kernel.org
Cc: clang-built-linux@googlegroups.com
Link: https://github.com/ClangBuiltLinux/linux/issues/534
Link: https://lkml.kernel.org/r/20190614181604.112297-1-nhuck@google.com

---
 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-23 10:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 18:16 [PATCH] timer_list: Fix Wunused-const-variable Nathan Huckleberry
2019-06-14 21:24 ` Nick Desaulniers
2019-06-23 10:22 ` [tip:timers/core] timer_list: Guard procfs specific code tip-bot for Nathan Huckleberry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®