Skip to contentSkip to conversation

Removed less than zero check, since Schedule_timeout return value is guaranteed to be non-negative

PATCH New Sasikantha babu 1 participant 1 message Apr 10, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Removed less than zero check, since Schedule_timeout return value is guaranteed to be non-negative

validating timeout against negiatve value is not required, schedule_timeout always returns >= 0.

If someone passes timeout as negative value, Instead of simply returning -ETIME we have to warn them (schedule_timeout is already doing it by dumping stack and priniting an error message) about it.

We must return -ETIME on timer expiry not for invaild timeouts.

---
 kernel/semaphore.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/semaphore.c +1 -1
index 60636a4..029c05b 100644
@@ -214,7 +214,7 @@ static inline int __sched __down_common(struct semaphore *sem, long state,
 	for (;;) {
 		if (signal_pending_state(state, task))
 			goto interrupted;
-		if (timeout <= 0)
+		if (!timeout)
 			goto timed_out;
 		__set_task_state(task, state);
 		raw_spin_unlock_irq(&sem->lock);
Signature · 1 line
1.7.3.4