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

From: Jesper Juhl
Date: Sat Apr 16 2005 - 08:53:30 EST


On Fri, 15 Apr 2005, Ingo Molnar wrote:

>
> * 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)
>

Right, that's a better version. Thanks.

--
Jesper

-
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/