From 56e9f1978d3305be4a235c4dddddc112d9beea16 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Tue, 2 Jul 2013 23:11:38 +0200 Subject: [PATCH] Fix warning increasing required alignment acr122_usb.c:513:20: warning: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align] uint32_t *pu32 = (uint32_t *)u8; ^~~~~~~~~~~~~~ --- libnfc/drivers/acr122_usb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c index efd65d4..9d6f5c4 100644 --- a/libnfc/drivers/acr122_usb.c +++ b/libnfc/drivers/acr122_usb.c @@ -505,13 +505,15 @@ uint32_t htole32(uint32_t u32); uint32_t htole32(uint32_t u32) { - uint8_t u8[4]; + union { + uint8_t arr[4]; + uint32_t u32; + } u; for (int i = 0; i < 4; i++) { - u8[i] = (u32 & 0xff); + u.arr[i] = (u32 & 0xff); u32 >>= 8; } - uint32_t *pu32 = (uint32_t *)u8; - return *pu32; + return u.u32; } #endif /* !defined(htole32) */