aboutsummaryrefslogtreecommitdiff
path: root/kernel/posix-timers.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-09-22 14:42:49 -0700
committerThomas Gleixner <tglx@linutronix.de>2008-09-24 15:45:48 +0200
commitef864c958801768fb28bd3603cd0b098b394671c (patch)
treeea0291b5f3281b1e7d4432dd8c31e1182446cd89 /kernel/posix-timers.c
parent717835d94d3e3d343a302df0a3cb9405887c3e2a (diff)
posix-timers: sys_timer_create: cleanup the error handling
Cleanup. - sys_timer_create() is big and complicated. The code above the "out:" label relies on the fact that "error" must be == 0. This is not very robust, make the code more explicit. Remove the unneeded initialization of error. - If idr_get_new() succeeds (as it normally should), we check the returned value twice. Move the "-EAGAIN" check under "if (error)". Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: mingo@elte.hu Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/posix-timers.c')
-rw-r--r--kernel/posix-timers.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index c459b29efdd..7be385fe4ec 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -454,9 +454,8 @@ sys_timer_create(const clockid_t which_clock,
struct sigevent __user *timer_event_spec,
timer_t __user * created_timer_id)
{
- int error = 0;
struct k_itimer *new_timer;
- int new_timer_id;
+ int error, new_timer_id;
struct task_struct *process;
sigevent_t event;
int it_id_set = IT_ID_NOT_SET;
@@ -478,9 +477,9 @@ sys_timer_create(const clockid_t which_clock,
error = idr_get_new(&posix_timers_id, (void *) new_timer,
&new_timer_id);
spin_unlock_irq(&idr_lock);
- if (error == -EAGAIN)
- goto retry;
- else if (error) {
+ if (error) {
+ if (error == -EAGAIN)
+ goto retry;
/*
* Weird looking, but we return EAGAIN if the IDR is
* full (proper POSIX return value for this)
@@ -541,6 +540,8 @@ sys_timer_create(const clockid_t which_clock,
new_timer->it_process = process;
list_add(&new_timer->list, &current->signal->posix_timers);
spin_unlock_irq(&current->sighand->siglock);
+
+ return 0;
/*
* In the case of the timer belonging to another task, after
* the task is unlocked, the timer is owned by the other task
@@ -548,9 +549,7 @@ sys_timer_create(const clockid_t which_clock,
* new_timer after the unlock call.
*/
out:
- if (error)
- release_posix_timer(new_timer, it_id_set);
-
+ release_posix_timer(new_timer, it_id_set);
return error;
}