diff options
author | Ned Bass <[email protected]> | 2012-12-26 14:56:41 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-01-07 11:21:52 -0800 |
commit | 37f000c5aa76613e644cf3e5b1ec7bd2df6f7451 (patch) | |
tree | e78020f4794ff324e6512c03c7a5c3b193349c54 /module/zfs/dmu_traverse.c | |
parent | e44056fcb644496b4dee4847164afe0bb2e04e5b (diff) |
Fix gcc array subscript above bounds warning
In a debug build, certain GCC versions flag an array bounds warning in
the below code from dnode_sync.c
} else {
int i;
ASSERT(dn->dn_next_nblkptr[txgoff] < dnp->dn_nblkptr);
/* the blkptrs we are losing better be unallocated */
for (i = dn->dn_next_nblkptr[txgoff];
i < dnp->dn_nblkptr; i++)
ASSERT(BP_IS_HOLE(&dnp->dn_blkptr[i]));
This usage is in fact safe, since the ASSERT ensures the index does
not exceed to maximum possible number of block pointers. However gcc
can't determine that the assignment 'i = dn->dn_next_nblkptr[txgoff];'
falls within the array bounds so it issues a warning. To avoid this,
initialize i to zero to make gcc happy but skip the elements before
dn->dn_next_nblkptr[txgoff] in the loop body. Since a dnode contains
at most 3 block pointers this overhead should be negligible.
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #950
Diffstat (limited to 'module/zfs/dmu_traverse.c')
0 files changed, 0 insertions, 0 deletions