Re: [PATCH] sched: fix never executed code due to expression always false

From: Ingo Molnar
Date: Fri Apr 15 2005 - 02:59:25 EST



* Jesper Juhl <juhl-lkml@xxxxxx> wrote:

> As per this patch perhaps? :
>
> Signed-off-by: Jesper Juhl <juhl-lkml@xxxxxx>

this is still not enough (there was one more comparison to cover). Also,
it's a bit cleaner to just cast the left side to signed than cast every
member separately.

Ingo

--

fix signed comparisons of long long.

Signed-off-by: Jesper Juhl <juhl-lkml@xxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>

--- linux/kernel/sched.c.orig
+++ linux/kernel/sched.c
@@ -2695,9 +2695,9 @@ need_resched_nonpreemptible:

schedstat_inc(rq, sched_cnt);
now = sched_clock();
- if (likely((long long)now - prev->timestamp < NS_MAX_SLEEP_AVG)) {
+ if (likely((long long)(now - prev->timestamp) < NS_MAX_SLEEP_AVG)) {
run_time = now - prev->timestamp;
- if (unlikely((long long)now - prev->timestamp < 0))
+ if (unlikely((long long)(now - prev->timestamp) < 0))
run_time = 0;
} else
run_time = NS_MAX_SLEEP_AVG;
@@ -2775,7 +2775,7 @@ go_idle:

if (!rt_task(next) && next->activated > 0) {
unsigned long long delta = now - next->timestamp;
- if (unlikely((long long)now - next->timestamp < 0))
+ if (unlikely((long long)(now - next->timestamp) < 0))
delta = 0;

if (next->activated == 1)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/