lkml.org 
[lkml]   [2014]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] FS/OMFS: block number sanity check during fill_super operation
On Thu, 26 Jun 2014 11:35:57 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Jun 26, 2014 11:28 AM, "Fabian Frederick" <fabf@skynet.be> wrote:
> >
> > Sorry but I don't see a problem with 2^31 value.
>
> It's not really 2^31.
>
> It's *negative* 2^31.
>
> 1 is "int", so it's a signed number. With the shift it ends up being a
> signed number with the high bit set. That's just a bad bad idea.
>
> Now, it just so happens that if you always compare it with unsigned
> numbers, C promotion rules will end up promoting it to unsigned and it
> happens to *work*, but that is more luck than design.
>
> So I'd suggest using 0x80000000 (which is unsigned) or use (1ul<<31) or
> similar explicit C typing.

Ok, I understand now. Thanks a lot for taking the time to explain Linus.
It really means a lot to me.

Fabian
>
> Linus


\
 
 \ /
  Last update: 2014-06-26 21:21    [W:0.121 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site