lkml.org 
[lkml]   [2019]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] atm: he: fix sign-extension overflow on large shift
On Tue, Jan 15, 2019 at 06:03:38PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Shifting the 1 by exp by an int can lead to sign-extension overlow when
> exp is 31 since 1 is an signed int and sign-extending this result to an
> unsigned long long will set the upper 32 bits. Fix this by shifting an
> unsigned long.

You could just cast it to unsigned.

rate_cps = (unsigned long long) (1U << exp) * (man + 512) >> 9;

I don't think it makes a difference at runtime because we just
pick buf = 4 either way...

regards,
dan carpenter

\
 
 \ /
  Last update: 2019-01-16 09:52    [W:1.397 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site