Commit 154860d9 authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka
Browse files

drivers/testing: headcheck: remove variable-length array


Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
parent 07a626a1
...@@ -59,19 +59,19 @@ static inline void breathe(int loops) ...@@ -59,19 +59,19 @@ static inline void breathe(int loops)
rtdm_task_sleep(300000ULL); rtdm_task_sleep(300000ULL);
} }
static inline void do_swap(void *left, void *right, const size_t size) static inline void do_swap(void *left, void *right)
{ {
char trans[size]; char trans[sizeof(struct chunk)];
memcpy(trans, left, size); memcpy(trans, left, sizeof(struct chunk));
memcpy(left, right, size); memcpy(left, right, sizeof(struct chunk));
memcpy(right, trans, size); memcpy(right, trans, sizeof(struct chunk));
} }
static void random_shuffle(void *vbase, size_t nmemb, const size_t size) static void random_shuffle(void *vbase, size_t nmemb)
{ {
struct { struct {
char x[size]; char x[sizeof(struct chunk)];
} __attribute__((packed)) *base = vbase; } __attribute__((packed)) *base = vbase;
unsigned int j, k; unsigned int j, k;
...@@ -79,7 +79,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) ...@@ -79,7 +79,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size)
k = (unsigned int)(prandom_u32() % nmemb) + 1; k = (unsigned int)(prandom_u32() % nmemb) + 1;
if (j == k) if (j == k)
continue; continue;
do_swap(&base[j - 1], &base[k - 1], size); do_swap(&base[j - 1], &base[k - 1]);
} }
} }
...@@ -259,7 +259,7 @@ static int test_seq(size_t heap_size, size_t block_size, int flags) ...@@ -259,7 +259,7 @@ static int test_seq(size_t heap_size, size_t block_size, int flags)
} }
if (flags & RTTST_HEAPCHECK_SHUFFLE) if (flags & RTTST_HEAPCHECK_SHUFFLE)
random_shuffle(chunks, nrblocks, sizeof(*chunks)); random_shuffle(chunks, nrblocks);
/* /*
* Release all blocks. * Release all blocks.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment