xfs: work around bogus gcc warning in xfs_allocbt_init_cursor
PATCH 1/1 xfs: work around bogus gcc warning in xfs_allocbt_init_cursor
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.
fs/xfs/xfs_alloc_btree.c +6 -3
@@ -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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 7 lines · Christoph Hellwig
GCC 4.6 complains about an array subscript is above array bounds when using the btree index to index into the
agf_levelsarray. 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_UPDATEflag.
Ugh.
Quoted 16 lines
Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_alloc_btree.c
===================================================================fs/xfs/xfs_alloc_btree.c +0
-3@@ -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 )
fs/xfs/xfs_alloc_btree.c xfs_allocbt_init_cursor( · line 442
Quoted 10 lines
fs/xfs/xfs_alloc_btree.c +6
-0+ +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.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs