On 8/21/15 9:01 AM, rjohnston@xxxxxxx wrote: > The pointer math when calculating the address for the call to memset > is incorrect, so we are clearing the wrong memory location. > > i2gmap is of type i2gseg_t > > oldsize has already computed the pointer offset > oldsize = inomap.hnkmaplen * SEGPERHNK * sizeof(i2gseg_t); > the memset call is using > inomap.i2gmap + oldsize == &inomap.i2gmap[oldsize] > so we were doing the pointer math twice. > > We already compensate for the length of each item in oldsize so > adding need to add a (char *) cast to the memset parameter. What about just doing: memset(&inomap.i2gmap[numsegs - SEGPERHNK], 0, SEGPERHNK * sizeof(i2gseg_t)); which more clearly shows that we're setting the new array members to zero. (could do oldsegs = inomap.hnkmaplen * SEGPERHNK; prior to the hnkmaplen++, if that makes it any more readable...) *shrug* it seems a little clearer to me, anyway. Thanks, -Eric > --- > dump/inomap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: b/dump/inomap.c > =================================================================== > --- a/dump/inomap.c > +++ b/dump/inomap.c > @@ -1143,7 +1143,7 @@ cb_add_inogrp( void *arg1, intgen_t fsfd > return -1; > > /* zero the new portion of the i2gmap */ > - memset(inomap.i2gmap + oldsize, > + memset((char *)inomap.i2gmap + oldsize, > 0, > SEGPERHNK * sizeof(i2gseg_t)); > } > > _______________________________________________ > xfs mailing list > xfs@xxxxxxxxxxx > http://oss.sgi.com/mailman/listinfo/xfs > _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs