aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorChris Kay <chris.kay@arm.com>2018-08-08 13:14:36 +0100
committerronald-cron-arm <39518861+ronald-cron-arm@users.noreply.github.com>2018-08-23 17:51:01 +0200
commita7fdf0dea3e30ba55fcadf3b0e32d115b0f09ddd (patch)
tree75d5adb2208dec2373d146f9d57f1004b6d0cae5 /module
parentf4e350027e2f1a049a30fd66d655bc29d1899bb6 (diff)
misc: Fix `dereferencing type-punned pointer will break...` errors
Fix `dereferencing type-punned pointer will break strict-aliasing rules` errors. Change-Id: I3eef4c8df85104e1b96edc7da7d5f68cf1455bfc Signed-off-by: Chris Kay <chris.kay@arm.com>
Diffstat (limited to 'module')
-rw-r--r--module/gtimer/src/mod_gtimer.c14
-rw-r--r--module/timer/src/mod_timer.c4
2 files changed, 9 insertions, 9 deletions
diff --git a/module/gtimer/src/mod_gtimer.c b/module/gtimer/src/mod_gtimer.c
index a1fd882d..dc195d23 100644
--- a/module/gtimer/src/mod_gtimer.c
+++ b/module/gtimer/src/mod_gtimer.c
@@ -138,6 +138,8 @@ static int get_timer(fwk_id_t dev_id, uint64_t *timestamp)
{
struct dev_ctx *ctx;
int status;
+ uint32_t counter_low;
+ uint32_t counter_high;
status = fwk_module_check_call(dev_id);
if (status != FWK_SUCCESS)
@@ -145,16 +147,12 @@ static int get_timer(fwk_id_t dev_id, uint64_t *timestamp)
ctx = ctx_table + fwk_id_get_element_idx(dev_id);
- struct {
- uint32_t low;
- uint32_t high;
- } value;
-
/* Read 64-bit timer value */
- value.low = ctx->hw_timer->P_CVALL;
- value.high = ctx->hw_timer->P_CVALH;
+ counter_low = ctx->hw_timer->P_CVALL;
+ counter_high = ctx->hw_timer->P_CVALH;
+
+ *timestamp = ((uint64_t)counter_high << 32) | counter_low;
- *timestamp = *(uint64_t *)&value;
return FWK_SUCCESS;
}
diff --git a/module/timer/src/mod_timer.c b/module/timer/src/mod_timer.c
index d3b7b115..8fc61399 100644
--- a/module/timer/src/mod_timer.c
+++ b/module/timer/src/mod_timer.c
@@ -10,6 +10,7 @@
#include <stdbool.h>
#include <stdint.h>
+#include <string.h>
#include <fwk_assert.h>
#include <fwk_element.h>
#include <fwk_errno.h>
@@ -493,7 +494,8 @@ static void timer_isr(uintptr_t ctx_ptr)
.target_id = alarm->listener,
.id = alarm->event_id,
};
- *(uintptr_t *)event.params = alarm->param; /* Word-size parameter */
+
+ memcpy(event.params, &alarm->param, sizeof(alarm->param));
status = fwk_thread_put_event(&event);
if (status != FWK_SUCCESS)