Skip to content

Commit

Permalink
sched/vtime: Work around an unitialized variable warning
Browse files Browse the repository at this point in the history
Work around this warning:

  kernel/sched/cputime.c: In function ‘kcpustat_field’:
  kernel/sched/cputime.c:1007:6: warning: ‘val’ may be used uninitialized in this function [-Wmaybe-uninitialized]

because GCC can't see that val is used only when err is 0.

Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20200327214334.GF8015@zn.tnic
  • Loading branch information
Borislav Petkov authored and Ingo Molnar committed Apr 15, 2020
1 parent 3662daf commit e0d648f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/sched/cputime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,12 @@ u64 kcpustat_field(struct kernel_cpustat *kcpustat,
enum cpu_usage_stat usage, int cpu)
{
u64 *cpustat = kcpustat->cpustat;
u64 val = cpustat[usage];
struct rq *rq;
u64 val;
int err;

if (!vtime_accounting_enabled_cpu(cpu))
return cpustat[usage];
return val;

rq = cpu_rq(cpu);

Expand Down

0 comments on commit e0d648f

Please sign in to comment.