[MONARCH_LTS] bug: linux-generic: add syntax to allow newer clang to compile odp

Message ID 20170711214833.29768-1-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer July 11, 2017, 9:48 p.m.
Resolve Bug https://bugs.linaro.org/show_bug.cgi?id=2942 by adding
casts needed to avoid compilation failures when using clang 4.0.0
included in Ubuntu 17.04, which is stricter than clang 3.8.1 which
is in Ubuntu 16.10.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
 helper/chksum.c                           | 6 +++---
 platform/linux-generic/odp_packet_flags.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.11.0

Patch

diff --git a/helper/chksum.c b/helper/chksum.c
index 8f188814..772abcd2 100644
--- a/helper/chksum.c
+++ b/helper/chksum.c
@@ -122,7 +122,7 @@  static inline int odph_process_l4_hdr(odp_packet_t     odp_pkt,
 		 * should come from the udp header, unlike for TCP where is
 		 * derived. */
 		l4_len            = odp_be_to_cpu_16(udp_hdr_ptr->length);
-		pkt_chksum_ptr    = &udp_hdr_ptr->chksum;
+		pkt_chksum_ptr    = (uint16_t *)(void *)&udp_hdr_ptr->chksum;
 		pkt_chksum_offset = l4_offset + offsetof(odph_udphdr_t, chksum);
 	} else if (odp_packet_has_tcp(odp_pkt)) {
 		tcp_hdr_ptr  = (odph_tcphdr_t *)l4_ptr;
@@ -133,7 +133,7 @@  static inline int odph_process_l4_hdr(odp_packet_t     odp_pkt,
 			tcp_hdr_ptr = &tcp_hdr;
 		}
 
-		pkt_chksum_ptr    = &tcp_hdr_ptr->cksm;
+		pkt_chksum_ptr    = (uint16_t *)(void *)&tcp_hdr_ptr->cksm;
 		pkt_chksum_offset = l4_offset + offsetof(odph_tcphdr_t, cksm);
 		is_tcp            = true;
 	} else {
@@ -197,7 +197,7 @@  static inline int odph_process_l3_hdr(odp_packet_t odp_pkt,
 			ipv4_hdr_ptr = &ipv4_hdr;
 		}
 
-		addrs_ptr = (uint16_t *)&ipv4_hdr_ptr->src_addr;
+		addrs_ptr = (uint16_t *)(void *)&ipv4_hdr_ptr->src_addr;
 		addrs_len = 2 * ODPH_IPV4ADDR_LEN;
 		protocol  = ipv4_hdr_ptr->proto;
 		l3_len    = odp_be_to_cpu_16(ipv4_hdr_ptr->tot_len);
diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c
index b88324c1..fc0bc1d2 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -18,7 +18,7 @@ 
 	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \
 	if (packet_parse_not_complete(pkt_hdr))          \
 		packet_parse_full(pkt_hdr);              \
-	pkt_hdr->p.x = v & 1;                            \
+	pkt_hdr->p.x = (v) & 1;				 \
 	} while (0)
 
 int odp_packet_has_error(odp_packet_t pkt)