[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1380572952-30729-4-git-send-email-andi@firstfloor.org>
Date: Mon, 30 Sep 2013 13:29:04 -0700
From: Andi Kleen <andi@...stfloor.org>
To: linux-kernel@...r.kernel.org
Cc: Andi Kleen <ak@...ux.intel.com>, tglx@...utronix.de
Subject: [PATCH 03/11] posix-timers: Initialize timer value to 0 for invalid timers.
From: Andi Kleen <ak@...ux.intel.com>
cpu_clock_sample et.al. can fail with an invalid timer type.
For most callers this cannot happen because the timer has been
successfully initialized earlier, so they don't check
the return value, but still use the val output.
Unfortunately static checkers for uninitialied variables
don't understand this and always throw a warning in this case.
Initialize the timer value to 0 for the error case to
shut it up.
This doesn't fix any real bug, just reduces warning noise.
Cc: tglx@...utronix.de
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
---
kernel/posix-cpu-timers.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index c7f31aa..cc3c3f2 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -182,6 +182,7 @@ static int cpu_clock_sample(const clockid_t which_clock, struct task_struct *p,
{
switch (CPUCLOCK_WHICH(which_clock)) {
default:
+ *sample = 0;
return -EINVAL;
case CPUCLOCK_PROF:
*sample = prof_ticks(p);
@@ -243,6 +244,7 @@ static int cpu_clock_sample_group(const clockid_t which_clock,
switch (CPUCLOCK_WHICH(which_clock)) {
default:
+ *sample = 0;
return -EINVAL;
case CPUCLOCK_PROF:
thread_group_cputime(p, &cputime);
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists