From: Peter Zijlstra Date: Wed, 6 Oct 2021 08:12:05 +0000 (+0200) Subject: sched: Fix DEBUG && !SCHEDSTATS warn X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=769fdf83df57b373660343ef4270b3ada91ef434;p=uclinux-h8%2Flinux.git sched: Fix DEBUG && !SCHEDSTATS warn When !SCHEDSTATS schedstat_enabled() is an unconditional 0 and the whole block doesn't exist, however GCC figures the scoped variable 'stats' is unused and complains about it. Upgrade the warning from -Wunused-variable to -Wunused-but-set-variable by writing it in two statements. This fixes the build because the new warning is in W=1. 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. Fixes: cb3e971c435d ("sched: Make struct sched_statistics independent of fair sched class") Reported-by: Stephen Rothwell Signed-off-by: Peter Zijlstra (Intel) --- diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 26fac5e28bc0..7dcbaa31c5d9 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -463,7 +463,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);