Qu Wenruo <quwen...@cn.fujitsu.com> on Wed, 2014/06/04 14:48:
> 
> -------- Original Message --------
> Subject: [PATCH 1/1] btrfs-progs: fix compiler warning
> From: Christian Hesse <m...@eworm.de>
> To: linux-btrfs@vger.kernel.org
> Date: 2014年06月03日 19:29
> > gcc 4.9.0 gives a warning: array subscript is above array bounds
> >
> > Checking for "greater or equal" instead of just "equal" fixes this.
> >
> > Signed-off-by: Christian Hesse <m...@eworm.de>
> > ---
> >   cmds-restore.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/cmds-restore.c b/cmds-restore.c
> > index 96b97e1..534a49e 100644
> > --- a/cmds-restore.c
> > +++ b/cmds-restore.c
> > @@ -169,7 +169,7 @@ again:
> >                     break;
> >     }
> >   
> > -   if (level == BTRFS_MAX_LEVEL)
> > +   if (level >= BTRFS_MAX_LEVEL)
> >             return 1;
> >   
> >     slot = path->slots[level] + 1;
>
> Also I faied to reproduce the bug.
> Using gcc-4.9.0-3 from Archlinux core repo.

Exactly the same here. ;)

> It seems to be related to default gcc flags from distribution?

Probably. I did compile with optimization, so adding -O2 may do the trick:

make CFLAGS="${CFLAGS} -O2" all
-- 
Schoene Gruesse
Chris
                         O< ascii ribbon campaign
                   stop html mail - www.asciiribbon.org

Attachment: signature.asc
Description: PGP signature

Reply via email to