Messages in this thread Patch in this message | | | From | Andi Kleen <> | Subject | [PATCH 03/11] posix-timers: Initialize timer value to 0 for invalid timers. | Date | Mon, 30 Sep 2013 13:29:04 -0700 |
| |
From: Andi Kleen <ak@linux.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@linutronix.de Signed-off-by: Andi Kleen <ak@linux.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
| |