From bb724cad016fba5775e751c817df0a07136d223f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 18 Mar 2019 20:44:38 +0100 Subject: ipcpd: Fix strict aliasing warning Some versions of gcc seem to give a positive on the strict aliasing rule. It's absent from newer gcc versions or clang. However, rather than disabling the check for older version, this small rewrite seems to temporarily fix the false positive. Apparently, it's undefined behaviour to simply cast a char/uint8_t buffer to a variable type pointer and then dereference the type. A more elaborate patch to fix the undefined behaviour is needed. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/udp/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ipcpd/udp/main.c b/src/ipcpd/udp/main.c index 559be55a..9f45bc73 100644 --- a/src/ipcpd/udp/main.c +++ b/src/ipcpd/udp/main.c @@ -438,14 +438,16 @@ static void * ipcp_udp_mgmt_handler(void * o) static void * ipcp_udp_packet_reader(void * o) { - uint8_t buf[IPCP_UDP_MAX_PACKET_SIZE]; - uint8_t * data; - ssize_t n; - uint32_t eid; + uint8_t buf[IPCP_UDP_MAX_PACKET_SIZE]; + uint8_t * data; + ssize_t n; + uint32_t eid; + uint32_t * eid_p; (void) o; - data = buf + sizeof(uint32_t); + data = buf + sizeof(uint32_t); + eid_p = (uint32_t *) buf; while (true) { struct mgmt_frame * frame; @@ -467,7 +469,7 @@ static void * ipcp_udp_packet_reader(void * o) continue; } - eid = ntoh32(*((uint32_t *) buf)); + eid = ntoh32(*eid_p); /* pass onto mgmt queue */ if (eid == MGMT_EID) { -- cgit v1.2.3