From f9be7a36f6ee890cde43700306e82d28ec94de3e Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 6 Dec 2016 13:33:35 -0700 Subject: [PATCH] examples/ioat/verify: fix misaligned pointer Dereferencing a non-8-byte-aligned uint64_t pointer is undefined behavior (caught by UBSan). Use memcmp() instead for an equivalent test that works at any byte alignment. Change-Id: I641b11abe9c5fc99d4c57b0b4ba15eb6a8d6d000 Signed-off-by: Daniel Verkamp --- examples/ioat/verify/verify.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/ioat/verify/verify.c b/examples/ioat/verify/verify.c index 03fc7a1f2..9498b86a6 100644 --- a/examples/ioat/verify/verify.c +++ b/examples/ioat/verify/verify.c @@ -163,20 +163,20 @@ static void prepare_ioat_task(struct thread_entry *thread_entry, struct ioat_tas static void ioat_done(void *cb_arg) { - uint64_t *value; + char *value; int i, failed = 0; struct ioat_task *ioat_task = (struct ioat_task *)cb_arg; struct thread_entry *thread_entry = ioat_task->thread_entry; if (ioat_task->type == IOAT_FILL_TYPE) { - value = (uint64_t *)ioat_task->dst; + value = ioat_task->dst; for (i = 0; i < ioat_task->len / 8; i++) { - if (*value != ioat_task->fill_pattern) { + if (memcmp(value, &ioat_task->fill_pattern, 8) != 0) { thread_entry->fill_failed++; failed = 1; break; } - value++; + value += 8; } if (!failed) thread_entry->fill_completed++;