[LTP] [PATCH v2] hugetlb/hugemmap: add new testcase hugemmap06.c

Cyril Hrubis chrubis@suse.cz
Thu Nov 26 14:59:24 CET 2015


Hi!
> > +		mmap_sz[i].sz = sz;
> > +		mmap_sz[i].addr = addr;
> > +
> > +		TEST(pthread_create(tid + i, NULL, thr, &mmap_sz[i]));
> 
> This is not right, use tid[i] ( = tid + sizeof(pthread_t) * i), not tid + i.

Hmm, since when arr + i != &arr[i] ?

When arr is pthread_t * type it's incremented by sizeof(pthread_t). As
far as I know arr[i] is just shorthand for *(arr + i). Which is a reason
why obscure things like i[arr] compile and give the same answer as
arr[i] even then technically the value is undefined.

If you want to increment pointer by 1 you have to explicitly cast it to
char * or intptr_t.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the Ltp mailing list