All of
 help / color / mirror / Atom feed
From: Borislav Petkov <>
To: Peter Zijlstra <>
Cc: x86-ml <>, lkml <>
Subject: [PATCH] sched/vtime: Fix an unitialized variable warning
Date: Fri, 27 Mar 2020 22:43:34 +0100	[thread overview]
Message-ID: <20200327214334.GF8015@zn.tnic> (raw)

Hi dude,

right before I was going to send the trivial, shut-up-gcc variant, I
thought that maybe we should do this instead.



  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]
   1007 |  u64 val;
        | ^~~

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

Signed-off-by: Borislav Petkov <>
 kernel/sched/cputime.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index dac9104d126f..ff9435dee1df 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -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);


             reply	other threads:[~2020-03-27 21:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 21:43 Borislav Petkov [this message]
2020-03-30 14:35 ` Peter Zijlstra
2020-04-15  9:14 ` [tip: sched/urgent] sched/vtime: Work around " tip-bot2 for Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200327214334.GF8015@zn.tnic \ \ \ \ \
    --subject='Re: [PATCH] sched/vtime: Fix an unitialized variable warning' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.