From mboxrd@z Thu Jan 1 00:00:00 1970 From: Antonio Quartulli Subject: [PATCH 13/16] batman-adv: add build check macros for packet member offset Date: Wed, 9 Oct 2013 14:40:15 +0200 Message-ID: <1381322418-1349-14-git-send-email-antonio@meshcoding.com> References: <1381322418-1349-1-git-send-email-antonio@meshcoding.com> Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Simon Wunderlich , Simon Wunderlich , Marek Lindner , Antonio Quartulli To: davem@davemloft.net Return-path: Received: from s3.neomailbox.net ([178.209.62.157]:18538 "EHLO s3.neomailbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751927Ab3JIN2x (ORCPT ); Wed, 9 Oct 2013 09:28:53 -0400 In-Reply-To: <1381322418-1349-1-git-send-email-antonio@meshcoding.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Simon Wunderlich Since we removed the __packed from most of the packets, we should make sure that the offset generated by the compiler are correct for sent/received data. Signed-off-by: Simon Wunderlich Signed-off-by: Marek Lindner Signed-off-by: Antonio Quartulli --- net/batman-adv/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 43dc92e..b22368e 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -393,6 +393,14 @@ static void batadv_recv_handler_init(void) for (i = 0; i < ARRAY_SIZE(batadv_rx_handler); i++) batadv_rx_handler[i] = batadv_recv_unhandled_packet; + /* compile time checks for struct member offsets */ + BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10); + BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); + BUILD_BUG_ON(offsetof(struct batadv_unicast_frag_packet, dest) != 4); + BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4); + BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4); + BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4); + /* batman icmp packet */ batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; /* unicast with 4 addresses packet */ -- 1.8.3.2