X-Spam-Checker-Version: SpamAssassin 3.4.0-r929098 (2010-03-30) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.4.0-r929098 Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id o8GGfGLe003470 for ; Thu, 16 Sep 2010 11:41:16 -0500 Received: from cf--amer001e--3.americas.sgi.com (cf--amer001e--3.americas.sgi.com [137.38.100.5]) by relay1.corp.sgi.com (Postfix) with ESMTP id A1A2D8F80A3; Thu, 16 Sep 2010 09:42:03 -0700 (PDT) Received: from [128.162.232.177] ([128.162.232.177]) by cf--amer001e--3.americas.sgi.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 16 Sep 2010 11:42:03 -0500 Subject: Re: [PATCH] 2.6.35.4: Fixed simple warning (array subscript is above array bounds) From: Alex Elder Reply-To: aelder@sgi.com To: Poyo VL Cc: xfs@oss.sgi.com In-Reply-To: <388312.90213.qm@web45811.mail.sp1.yahoo.com> References: <388312.90213.qm@web45811.mail.sp1.yahoo.com> Content-Type: text/plain; charset="UTF-8" Date: Thu, 16 Sep 2010 11:42:02 -0500 Message-ID: <1284655322.2153.22.camel@doink> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: quoted-printable X-OriginalArrivalTime: 16 Sep 2010 16:42:03.0523 (UTC) FILETIME=[176B0D30:01CB55BE] X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on oss.sgi.com X-Virus-Status: Clean On Thu, 2010-09-02 at 02:10 -0700, Poyo VL wrote: > From: Ionut Gabriel Popescu >=20 > When I tried to compile, I got the following warning: > fs/xfs/xfs_dir2_block.c: In function =E2=80=98xfs_dir2_sf_to_block=E2=80= =99: > fs/xfs/xfs_dir2_block.c:1153:26: warning: array subscript is above array = bounds > The code (fs/xfs/xfs_dir2_block.c line 1153) is: > dep->name[0] =3D dep->name[1] =3D '.'; > dep is a pointer to a xfs_dir2_data_entry_t structure where name is defin= ed as: > __u8 name[1]; /* name bytes, no null */ > So it is a single element array, name[0] not also name[1] so I got that w= arning. > Patching is a simple replacement of 1 with 2. It looks to me like this will work. But I would like a second opinion on that before I commit this change. An xfs_dir2_data_entry structure is defined the way it is to be informative; its physical representation is different when it's actually used. The name array is sized based on the actual name length, and the tag lies somewhere after that--at the very end of the (dynamically-sized) data entry. Additionally, the alignment of the overall structure will be 64 bits because of hte inumber field. Expanding the name field by another byte will not change that. So I think this change is OK. Can anyone else back me up? Reviewed-by: Alex Elder > Signed-off-by: Ionut Gabriel Popescu > --- >=20 > --- a/fs/xfs/xfs_dir2_data.h 2010-09-02 11:13:11.632007536 +0300 > +++ b/fs/xfs/xfs_dir2_data.h 2010-09-02 11:13:28.080006488 +0300 > @@ -87,7 +87,7 @@ > typedef struct xfs_dir2_data_entry { > __be64 inumber; /* inode number */ > __u8 namelen; /* name length */ > - __u8 name[1]; /* name bytes, no null */ > + __u8 name[2]; /* name bytes, no null */ > /* variable offset */ > __be16 tag; /* starting offset of us */ > } xfs_dir2_data_entry_t; >=20 >=20 > =20