From 60354cbea29c88884f3b99b40bfa257b047717b1 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Mon, 18 Sep 2017 14:56:46 -0700 Subject: [PATCH] clang fix, don't allow unaligned uint64_t pointers --- src/target/riscv/batch.c | 13 ++++++++++--- src/target/riscv/batch.h | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/target/riscv/batch.c b/src/target/riscv/batch.c index 56d51a19c..1e6a4be92 100644 --- a/src/target/riscv/batch.c +++ b/src/target/riscv/batch.c @@ -103,7 +103,7 @@ size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address) batch->read_keys[batch->read_keys_used] = batch->used_scans - 1; LOG_DEBUG("read key %u for batch 0x%p is %u (0x%p)", (unsigned) batch->read_keys_used, batch, (unsigned) (batch->used_scans - 1), - (uint64_t*)batch->data_in + (batch->used_scans + 1)); + batch->data_in + sizeof(uint64_t) * (batch->used_scans + 1)); return batch->read_keys_used++; } @@ -112,8 +112,15 @@ uint64_t riscv_batch_get_dmi_read(struct riscv_batch *batch, size_t key) assert(key < batch->read_keys_used); size_t index = batch->read_keys[key]; assert(index <= batch->used_scans); - uint64_t *addr = ((uint64_t *)(batch->data_in) + index); - return *addr; + uint8_t *base = batch->data_in + 8 * index; + return base[0] | + ((uint64_t) base[1]) << 8 | + ((uint64_t) base[2]) << 16 | + ((uint64_t) base[3]) << 24 | + ((uint64_t) base[4]) << 32 | + ((uint64_t) base[5]) << 40 | + ((uint64_t) base[6]) << 48 | + ((uint64_t) base[7]) << 56; } void riscv_batch_add_nop(struct riscv_batch *batch) diff --git a/src/target/riscv/batch.h b/src/target/riscv/batch.h index 776d93a79..835829b2b 100644 --- a/src/target/riscv/batch.h +++ b/src/target/riscv/batch.h @@ -23,8 +23,8 @@ struct riscv_batch { size_t idle_count; - char *data_out; - char *data_in; + uint8_t *data_out; + uint8_t *data_in; struct scan_field *fields; /* In JTAG we scan out the previous value's output when performing a