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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 15 Apr 2005, Ingo Molnar wrote:

> 
> * Jesper Juhl <[email protected]> wrote:
> 
> > As per this patch perhaps? : 
> > 
> > Signed-off-by: Jesper Juhl <[email protected]>
> 
> 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 <[email protected]>
> Signed-off-by: Ingo Molnar <[email protected]>
> 
> --- 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux