[PATCH] Avoid pointer arithmetic on void* in test/integration/rallocx.c

Mike Hommey mh+jemalloc at glandium.org
Tue May 27 19:37:23 PDT 2014


On Tue, May 27, 2014 at 03:28:09PM -0700, Jason Evans wrote:
> On May 21, 2014, at 2:13 AM, Mike Hommey <mh+jemalloc at glandium.org> wrote:
> > ---
> > test/integration/rallocx.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/test/integration/rallocx.c b/test/integration/rallocx.c
> > index ee21aed..7acb211 100644
> > --- a/test/integration/rallocx.c
> > +++ b/test/integration/rallocx.c
> > @@ -95,7 +95,7 @@ TEST_BEGIN(test_zero)
> > 				    "Expected zeroed memory");
> > 			}
> > 			if (psz != qsz) {
> > -				memset(q+psz, FILL_BYTE, qsz-psz);
> > +				memset((char *)q+psz, FILL_BYTE, qsz-psz);
> > 				psz = qsz;
> > 			}
> > 			p = q;
> > @@ -159,8 +159,8 @@ TEST_BEGIN(test_lg_align_and_zero)
> > 		} else {
> > 			assert_false(validate_fill(q, 0, 0, MAX_VALIDATE),
> > 			    "Expected zeroed memory");
> > -			assert_false(validate_fill(q+sz-MAX_VALIDATE, 0, 0,
> > -			    MAX_VALIDATE), "Expected zeroed memory");
> > +			assert_false(validate_fill((char *)q+sz-MAX_VALIDATE,
> > +                            0, 0, MAX_VALIDATE), "Expected zeroed memory");
> > 		}
> > 		p = q;
> > 	}
> 
> Integrated, with minor modification:
> 
> 	https://github.com/jemalloc/jemalloc/commit/3a730dfd5062ecd6fc46b68f28342e14b461f560

Fails to build with C2036: 'void *' : unknown size

The problem is the (void *) cast doesn't apply to the result of the
addition.

Mike


More information about the jemalloc-discuss mailing list