]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
xfs: work around bogus gcc warning in xfs_allocbt_init_cursor
authorChristoph Hellwig <hch@lst.de>
Fri, 8 Jul 2011 12:34:18 +0000 (14:34 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 8 Jul 2011 12:34:18 +0000 (14:34 +0200)
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>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/xfs_alloc_btree.c

index 2b3518826a692640c46e3e4fb5f5192e418e868b..e277777a7cf9e7190a8933b902113f11efb7cefb 100644 (file)
@@ -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;