lkml.org 
[lkml]   [2013]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 03/11] posix-timers: Initialize timer value to 0 for invalid timers.
Date
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


\
 
 \ /
  Last update: 2013-09-30 23:01    [W:0.214 / U:0.844 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site