lkml.org 
[lkml]   [2015]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: sched: about vruntime overflow
Date
Much Thanks!


On Tue, Jul 07, 2015 at 08:05:50AM +0000, Gaohaifeng (A) wrote:
> int main()
> {
> unsigned char a,b;
> a=251;
> b=254;
> b +=5; // b will overflow
> printf("a=%u \n",a);
> printf("b=%u \n",b);
> printf("(a-b<0)=%d\n",(a-b)<0);

If you look at entity_before() you'll notice that the correct statement would be:

printf("(a-b<0)=%d\n",(signed char)(a-b)<0);

> printf("(a-b<0)=%d\n",((unsigned char)(a-250)-(unsigned char)(b-250)<0));
> return 0;
> }



\
 
 \ /
  Last update: 2015-07-07 11:41    [W:0.033 / U:0.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site