batman-adv: add build check macros for packet member offset
authorSimon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
Thu, 25 Apr 2013 08:37:22 +0000 (10:37 +0200)
committerAntonio Quartulli <antonio@meshcoding.com>
Wed, 9 Oct 2013 19:22:33 +0000 (21:22 +0200)
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 <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
net/batman-adv/main.c

index 43dc92e79a76152719261da8d091910ad2261528..b22368e66895b5198bc00da985c2baf32755147c 100644 (file)
@@ -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 */