On Mon, Sep 20, 2021 at 11:33:30AM +1000, Stephen Rothwell wrote: > Hi all, > > After merging the tip tree, today's linux-next build (powerpc_ppc64 > defconfig) produced this warning: > > kernel/sched/debug.c: In function 'print_cfs_group_stats': > kernel/sched/debug.c:460:41: warning: unused variable 'stats' [-Wunused-variable] > 460 | struct sched_statistics *stats = __schedstats_from_se(se); > | ^~~~~ > So I've not seen that one *yet*, I've dont a bunch of SCHEDSTAT=n builds. I do think GCC is being quite stupid for giving it, seeing how the whole thing is within if (0). The GCC people seem to disagree when I brought it up. Anyway, what I did in other parts was the below; that seems to 'upgrade' the warnings from -Wunused-variable to -Wunused-but-set-variable, and that latter *is* in W=1, and I'm arguing it should be promoted to W=2 or thereabout. Given that whole if(0) {} thing, I don't feel motivated to change things overly much and quite strongly feel this is the compiler being daft. --- diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 935dad7dffb7..ef71de01e4d7 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -457,7 +457,8 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group PN(se->sum_exec_runtime); if (schedstat_enabled()) { - struct sched_statistics *stats = __schedstats_from_se(se); + struct sched_statistics *stats; + stats = __schedstats_from_se(se); PN_SCHEDSTAT(wait_start); PN_SCHEDSTAT(sleep_start);