mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: sched:  about vruntime overflow
       [not found] <47CEA9C0E570484FBF22EF0D7EBCE5B534B17A98@szxema505-mbs.china.huawei.com>
@ 2015-07-07  9:10 ` Peter Zijlstra
  2015-07-07  9:18   ` Gaohaifeng (A)
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Zijlstra @ 2015-07-07  9:10 UTC (permalink / raw)
  To: Gaohaifeng (A); +Cc: linux-kernel, stephan.baerwolf, Huangjian (J)

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;
> }


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: sched:  about vruntime overflow
  2015-07-07  9:10 ` sched: about vruntime overflow Peter Zijlstra
@ 2015-07-07  9:18   ` Gaohaifeng (A)
  0 siblings, 0 replies; 2+ messages in thread
From: Gaohaifeng (A) @ 2015-07-07  9:18 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel, stephan.baerwolf, Huangjian (J)

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;
> }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-07  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <47CEA9C0E570484FBF22EF0D7EBCE5B534B17A98@szxema505-mbs.china.huawei.com>
2015-07-07  9:10 ` sched: about vruntime overflow Peter Zijlstra
2015-07-07  9:18   ` Gaohaifeng (A)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®