lkml.org 
[lkml]   [2016]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] ext4: underflow in alignment check
On Mon, Jun 20, 2016 at 06:02:04PM +0200, Jan Kara wrote:
> On Thu 16-06-16 10:07:09, Dan Carpenter wrote:
> > My static checker complains that this can underflow if arg is negative
> > which is true.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> How come? (1 << 30) fits even into 32-bit signed type. So where's the
> problem?

Bad changelog... I was talking about a different issue. I was casting
it to unsigned to take advantage of type promototion. Assume we have:

int arg = 1 << 31;

(arg > (1 << 30)) // <-- this is false
(arg > (1U << 30)) // <-- this is true so there is no underflow.

regards,
dan carpenter

\
 
 \ /
  Last update: 2016-06-20 22:41    [W:0.070 / U:0.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site