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;
                   ^~~~~~~~~~~~~~
This commit is contained in:
Philippe Teuwen 2013-07-02 23:11:38 +02:00
parent cc7c0c32f1
commit 56e9f1978d

View file

@ -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) */