lkml.org 
[lkml]   [2005]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] sched: fix never executed code due to expression always false
On Fri, 15 Apr 2005, Ingo Molnar wrote:

>
> * Jesper Juhl <juhl-lkml@dif.dk> wrote:
>
> > As per this patch perhaps? :
> >
> > Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
>
> 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@dif.dk>
> Signed-off-by: Ingo Molnar <mingo@elte.hu>
>
> --- 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-04-16 15:55    [W:0.046 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site