Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1426974

Re: [patch] ext4: underflow in alignment check

From Dan Carpenter <dan.carpenter@oracle.com>
Newsgroups linux.kernel
Subject Re: [patch] ext4: underflow in alignment check
Date 2016-06-20 22:00 +0200
Message-ID <rMdwt-44L-27@gated-at.bofh.it> (permalink)
References <rKzB7-5e9-9@gated-at.bofh.it> <rMa5z-24j-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[patch] ext4: underflow in alignment check Dan Carpenter <dan.carpenter@oracle.com> - 2016-06-16 09:10 +0200
  Re: [patch] ext4: underflow in alignment check Jan Kara <jack@suse.cz> - 2016-06-20 18:20 +0200
    Re: [patch] ext4: underflow in alignment check Dan Carpenter <dan.carpenter@oracle.com> - 2016-06-20 22:00 +0200
      Re: [patch] ext4: underflow in alignment check Jan Kara <jack@suse.cz> - 2016-06-21 09:50 +0200
        Re: [patch] ext4: underflow in alignment check Dan Carpenter <dan.carpenter@oracle.com> - 2016-06-21 15:10 +0200

csiph-web