* [PATCH] xfs: work around bogus gcc warning in xfs_allocbt_init_cursor
@ 2011-06-17 13:12 Christoph Hellwig
2011-06-21 0:05 ` Dave Chinner
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2011-06-17 13:12 UTC (permalink / raw)
To: xfs
GCC 4.6 complains about an array subscript is above array bounds when
using the btree index to index into the agf_levels array. The only
two indices passed in are 0 and 1, and we have an assert insuring that.
Replace the trick of using the array index directly with using constants
in the already existing branch for assigning the XFS_BTREE_LASTREC_UPDATE
flag.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: xfs/fs/xfs/xfs_alloc_btree.c
===================================================================
--- xfs.orig/fs/xfs/xfs_alloc_btree.c 2011-06-17 14:16:27.929065669 +0200
+++ xfs/fs/xfs/xfs_alloc_btree.c 2011-06-17 14:17:22.145729599 +0200
@@ -427,13 +427,16 @@ xfs_allocbt_init_cursor(
cur->bc_tp = tp;
cur->bc_mp = mp;
- cur->bc_nlevels = be32_to_cpu(agf->agf_levels[btnum]);
cur->bc_btnum = btnum;
cur->bc_blocklog = mp->m_sb.sb_blocklog;
-
cur->bc_ops = &xfs_allocbt_ops;
- if (btnum == XFS_BTNUM_CNT)
+
+ if (btnum == XFS_BTNUM_CNT) {
+ cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]);
cur->bc_flags = XFS_BTREE_LASTREC_UPDATE;
+ } else {
+ cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]);
+ }
cur->bc_private.a.agbp = agbp;
cur->bc_private.a.agno = agno;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs: work around bogus gcc warning in xfs_allocbt_init_cursor
2011-06-17 13:12 [PATCH] xfs: work around bogus gcc warning in xfs_allocbt_init_cursor Christoph Hellwig
@ 2011-06-21 0:05 ` Dave Chinner
0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2011-06-21 0:05 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Fri, Jun 17, 2011 at 09:12:14AM -0400, Christoph Hellwig wrote:
> GCC 4.6 complains about an array subscript is above array bounds when
> using the btree index to index into the agf_levels array. The only
> two indices passed in are 0 and 1, and we have an assert insuring that.
>
> Replace the trick of using the array index directly with using constants
> in the already existing branch for assigning the XFS_BTREE_LASTREC_UPDATE
> flag.
Ugh.
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Index: xfs/fs/xfs/xfs_alloc_btree.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_alloc_btree.c 2011-06-17 14:16:27.929065669 +0200
> +++ xfs/fs/xfs/xfs_alloc_btree.c 2011-06-17 14:17:22.145729599 +0200
> @@ -427,13 +427,16 @@ xfs_allocbt_init_cursor(
>
> cur->bc_tp = tp;
> cur->bc_mp = mp;
> - cur->bc_nlevels = be32_to_cpu(agf->agf_levels[btnum]);
> cur->bc_btnum = btnum;
> cur->bc_blocklog = mp->m_sb.sb_blocklog;
> -
> cur->bc_ops = &xfs_allocbt_ops;
> - if (btnum == XFS_BTNUM_CNT)
> +
> + if (btnum == XFS_BTNUM_CNT) {
> + cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]);
> cur->bc_flags = XFS_BTREE_LASTREC_UPDATE;
> + } else {
> + cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]);
> + }
>
> cur->bc_private.a.agbp = agbp;
> cur->bc_private.a.agno = agno;
Looks fine.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-21 0:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-17 13:12 [PATCH] xfs: work around bogus gcc warning in xfs_allocbt_init_cursor Christoph Hellwig
2011-06-21 0:05 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox