timer_list: Fix Wunused-const-variable
PATCH 1/1 timer_list: Fix Wunused-const-variable
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.
--- kernel/time/timer_list.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)
kernel/time/timer_list.c +19 -17
@@ -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
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
Quoted 9 lines · Nathan Huckleberry' via 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 structseq_operationstimer_list_sops= {Code reliant on
CONFIG_PROC_FSis not in ifdef guard. Created ifdef guard aroundproc_fsspecific 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.
Quoted 4 lines
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:
Quoted 71 lines
--- kernel/time/timer_list.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)kernel/time/timer_list.c +19
-18@@ -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 [email protected]. To post to this group, send email to [email protected].
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.
Signature · 2 lines
Thanks, ~Nick Desaulniers
tip-bot for Nathan Huckleberry
merge bot[tip:timers/core] timer_list: Guard procfs specific code
In reply to Nathan Huckleberrytimer_list: Guard procfs specific code
Commit-ID: a9314773a91a1d3b36270085246a6715a326ff00 Gitweb: https://git.kernel.org/tip/a9314773a91a1d3b36270085246a6715a326ff00 Author: Nathan Huckleberry <[email protected]> AuthorDate: Fri, 14 Jun 2019 11:16:04 -0700 Committer: Thomas Gleixner <[email protected]> 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.
--- kernel/time/timer_list.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)
kernel/time/timer_list.c +19 -17
@@ -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