0003-Fix-warnings.patch 28.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757
From cb47e0b69b747833322a83b7396878a631add116 Mon Sep 17 00:00:00 2001
From: Martine Lenders <mail@martine-lenders.eu>
Date: Fri, 5 Feb 2016 00:46:31 +0100
Subject: [PATCH 3/4] Fix warnings

---
 emb6/src/net/ipv6/multicast/roll-tm.c          | 82 ++++++++++++++++++------
 emb6/src/net/ipv6/multicast/smrf.c             | 12 +++-
 emb6/src/net/ipv6/multicast/uip-mcast6-route.c |  2 +-
 emb6/src/net/ipv6/tcpip.c                      | 25 ++++++--
 emb6/src/net/ipv6/uip-icmp6.c                  | 35 +++++++++--
 emb6/src/net/ipv6/uip-nd6.c                    | 74 ++++++++++++++++++----
 emb6/src/net/ipv6/uip6.c                       | 86 +++++++++++++++++++++-----
 emb6/src/net/rpl/rpl-ext-header.c              | 50 ++++++++++++---
 emb6/src/net/rpl/rpl-icmp6.c                   | 24 +++++--
 emb6/src/net/sicslowpan/sicslowpan.c           | 45 +++++++++++---
 emb6/src/tport/udp-socket.c                    |  7 ++-
 11 files changed, 365 insertions(+), 77 deletions(-)

diff --git a/emb6/src/net/ipv6/multicast/roll-tm.c b/emb6/src/net/ipv6/multicast/roll-tm.c
index 8b36300..96f4f47 100644
--- a/emb6/src/net/ipv6/multicast/roll-tm.c
+++ b/emb6/src/net/ipv6/multicast/roll-tm.c
@@ -290,12 +290,17 @@ struct mcast_packet {
 #define MCAST_PACKET_S_BIT       0x20   /* Must Send Next Pass */
 #define MCAST_PACKET_L_BIT       0x10   /* Is listed in ICMP message */

+static inline struct uip_ip_hdr *_to_ip_hdr(void *ptr)
+{
+    return (struct uip_ip_hdr *)ptr;
+}
+
 /* Fetch a pointer to the Seed ID of a buffered message p */
 #if ROLL_TM_SHORT_SEEDS
 #define MCAST_PACKET_GET_SEED(p) ((seed_id_t *)&((p)->seed_id))
 #else
 #define MCAST_PACKET_GET_SEED(p) \
-    ((seed_id_t *)&((struct uip_ip_hdr *)&(p)->buff[UIP_LLH_LEN])->srcipaddr)
+    ((seed_id_t *)&(((struct uip_ip_hdr *)&(p))->buff[UIP_LLH_LEN])->srcipaddr)
 #endif

 /**
@@ -303,7 +308,7 @@ struct mcast_packet {
  * p: pointer to a packet buffer
  */
 #define MCAST_PACKET_TTL(p) \
-    (((struct uip_ip_hdr *)(p)->buff)->ttl)
+    (_to_ip_hdr((p)->buff)->ttl)

 /**
  * \brief Set 'Is Used' bit for packet p
@@ -462,14 +467,55 @@ static uint16_t last_seq;
 /*---------------------------------------------------------------------------*/
 /* uIPv6 Pointers */
 /*---------------------------------------------------------------------------*/
-#define UIP_DATA_BUF      ((uint8_t *)&uip_buf[uip_l2_l3_hdr_len + UIP_UDPH_LEN])
-#define UIP_UDP_BUF       ((struct uip_udp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_EXT_BUF       ((struct uip_ext_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
-#define UIP_EXT_BUF_NEXT  ((uint8_t *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN + HBHO_TOTAL_LEN])
-#define UIP_EXT_OPT_FIRST ((struct hbho_mcast *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN + 2])
-#define UIP_IP_BUF        ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
-#define UIP_ICMP_BUF      ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_ICMP_PAYLOAD  ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len])
+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+static inline uint8_t *uip_data_buf(void)
+{
+    return ((uint8_t *)&uip_buf[uip_l2_l3_hdr_len + UIP_UDPH_LEN]);
+}
+
+static inline struct uip_udp_hdr *uip_udp_buf(void)
+{
+    return ((struct uip_udp_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_ext_hdr *uip_ext_buf(void)
+{
+    return ((struct uip_ext_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN]);
+}
+
+uint8_t *uip_ext_buf_next(void)
+{
+    return ((uint8_t *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN + HBHO_TOTAL_LEN]);
+}
+
+static inline struct hbho_mcast *uip_ext_opt_first(void)
+{
+    return ((struct hbho_mcast *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN + 2]);
+}
+
+static inline struct uip_ip_hdr *uip_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+static inline struct uip_icmp_hdr *uip_icmp_buf(void)
+{
+    return ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline unsigned char *uip_icmp_payload(void)
+{
+    return ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len]);
+}
+
+#define UIP_DATA_BUF      (uip_data_buf())
+#define UIP_UDP_BUF       (uip_udp_buf())
+#define UIP_EXT_BUF       (uip_ext_buf())
+#define UIP_EXT_BUF_NEXT  (uip_ext_buf_next())
+#define UIP_EXT_OPT_FIRST (uip_ext_opt_first())
+#define UIP_IP_BUF        (uip_ip_buf())
+#define UIP_ICMP_BUF      (uip_icmp_buf())
+#define UIP_ICMP_PAYLOAD  (uip_icmp_payload())
 extern uint16_t uip_slen;
 /*---------------------------------------------------------------------------*/
 /* Local function prototypes */
@@ -689,7 +735,7 @@ reset_trickle_timer(uint8_t index)
 }
 /*---------------------------------------------------------------------------*/
 static struct sliding_window *
-window_allocate()
+window_allocate(void)
 {
   for(iterswptr = &windows[ROLL_TM_WINS - 1]; iterswptr >= windows;
       iterswptr--) {
@@ -721,7 +767,7 @@ window_lookup(seed_id_t *s, uint8_t m)
 }
 /*---------------------------------------------------------------------------*/
 static void
-window_update_bounds()
+window_update_bounds(void)
 {
   for(iterswptr = &windows[ROLL_TM_WINS - 1]; iterswptr >= windows;
       iterswptr--) {
@@ -748,7 +794,7 @@ window_update_bounds()
 }
 /*---------------------------------------------------------------------------*/
 static struct mcast_packet *
-buffer_reclaim()
+buffer_reclaim(void)
 {
   struct sliding_window *largest = windows;
   struct mcast_packet *rv;
@@ -790,7 +836,7 @@ buffer_reclaim()
 }
 /*---------------------------------------------------------------------------*/
 static struct mcast_packet *
-buffer_allocate()
+buffer_allocate(void)
 {
   for(locmpptr = &buffered_msgs[ROLL_TM_BUFF_NUM - 1];
       locmpptr >= buffered_msgs; locmpptr--) {
@@ -802,7 +848,7 @@ buffer_allocate()
 }
 /*---------------------------------------------------------------------------*/
 static void
-icmp_output()
+icmp_output(void)
 {
   struct sequence_list_header *sl;
   uint8_t *buffer;
@@ -1098,7 +1144,7 @@ accept(uint8_t in)
 /*---------------------------------------------------------------------------*/
 /* ROLL TM ICMPv6 Input Handler */
 static void
-icmp_input()
+icmp_input(void)
 {
   uint8_t inconsistency;
   uint16_t *seq_ptr;
@@ -1321,7 +1367,7 @@ drop:
 }
 /*---------------------------------------------------------------------------*/
 static void
-out()
+out(void)
 {

   if(uip_len + HBHO_TOTAL_LEN > UIP_BUFSIZE) {
@@ -1391,7 +1437,7 @@ drop:
 }
 /*---------------------------------------------------------------------------*/
 static uint8_t
-in()
+in(void)
 {
   /*
    * We call accept() which will sort out caching and forwarding. Depending
diff --git a/emb6/src/net/ipv6/multicast/smrf.c b/emb6/src/net/ipv6/multicast/smrf.c
index 9b4a3a5..38d31cd 100644
--- a/emb6/src/net/ipv6/multicast/smrf.c
+++ b/emb6/src/net/ipv6/multicast/smrf.c
@@ -77,7 +77,13 @@ static uint8_t fwd_spread;
 /*---------------------------------------------------------------------------*/
 /* uIPv6 Pointers */
 /*---------------------------------------------------------------------------*/
-#define UIP_IP_BUF        ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+static inline struct uip_ip_hdr *uip_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+#define UIP_IP_BUF        (uip_ip_buf())
 /*---------------------------------------------------------------------------*/
 static void
 mcast_fwd(void *p)
@@ -90,7 +96,7 @@ mcast_fwd(void *p)
 }
 /*---------------------------------------------------------------------------*/
 static uint8_t
-in()
+in(void)
 {
   rpl_dag_t *d;                 /* Our DODAG */
   uip_ipaddr_t *parent_ipaddr;  /* Our pref. parent's IPv6 address */
@@ -201,7 +207,7 @@ init(void)
 }
 /*---------------------------------------------------------------------------*/
 static void
-out()
+out(void)
 {
   return;
 }
diff --git a/emb6/src/net/ipv6/multicast/uip-mcast6-route.c b/emb6/src/net/ipv6/multicast/uip-mcast6-route.c
index 55d245d..75443a5 100644
--- a/emb6/src/net/ipv6/multicast/uip-mcast6-route.c
+++ b/emb6/src/net/ipv6/multicast/uip-mcast6-route.c
@@ -126,7 +126,7 @@ uip_mcast6_route_count(void)
 }
 /*---------------------------------------------------------------------------*/
 void
-uip_mcast6_route_init()
+uip_mcast6_route_init(void)
 {
   memb_init(&mcast_route_memb);
   list_init(mcast_route_list);
diff --git a/emb6/src/net/ipv6/tcpip.c b/emb6/src/net/ipv6/tcpip.c
index 9c76bed..1901d9e 100644
--- a/emb6/src/net/ipv6/tcpip.c
+++ b/emb6/src/net/ipv6/tcpip.c
@@ -72,9 +72,24 @@ void uip_log(char *msg);
 #define UIP_LOG(m)
 #endif

-#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN + uip_ext_len])
-#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
-#define UIP_TCP_BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+static inline struct uip_icmp_hdr *uip_icmp_buf(void)
+{
+    return ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN + uip_ext_len]);
+}
+
+static inline struct uip_ip_hdr *uip_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+static inline struct uip_tcpip_hdr *uip_tcp_buf(void)
+{
+    return ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+#define UIP_ICMP_BUF (uip_icmp_buf())
+#define UIP_IP_BUF (uip_ip_buf())
+#define UIP_TCP_BUF (uip_tcp_buf())

 #ifdef UIP_FALLBACK_INTERFACE
 extern struct uip_fallback_interface UIP_FALLBACK_INTERFACE;
@@ -165,15 +180,15 @@ unsigned char tcpip_is_forwarding; /* Forwarding right now? */
 //PROCESS(tcpip_process, "TCP/IP stack");

 /*---------------------------------------------------------------------------*/
+#if UIP_TCP
 static void
 start_periodic_tcp_timer(void)
 {
-#if UIP_TCP
   if(etimer_expired(&periodic)) {
     etimer_restart(&periodic);
   }
-#endif /* UIP_TCP */
 }
+#endif /* UIP_TCP */
 /*---------------------------------------------------------------------------*/
 static void
 check_for_tcp_syn(void)
diff --git a/emb6/src/net/ipv6/uip-icmp6.c b/emb6/src/net/ipv6/uip-icmp6.c
index 484d0bf..6f53d12 100644
--- a/emb6/src/net/ipv6/uip-icmp6.c
+++ b/emb6/src/net/ipv6/uip-icmp6.c
@@ -59,11 +59,34 @@
 #define PRINT6ADDR(addr)
 #endif

-#define UIP_IP_BUF                ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
-#define UIP_ICMP_BUF            ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_ICMP6_ERROR_BUF  ((struct uip_icmp6_error *)&uip_buf[uip_l2_l3_icmp_hdr_len])
-#define UIP_EXT_BUF              ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_FIRST_EXT_BUF        ((struct uip_ext_hdr *)&uip_buf[UIP_LLIPH_LEN])
+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+static inline struct uip_ip_hdr *uip_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+static inline struct uip_icmp_hdr *uip_icmp_buf(void)
+{
+    return ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_icmp6_error *uip_icmp6_error_buf(void) {
+    return ((struct uip_icmp6_error *)&uip_buf[uip_l2_l3_icmp_hdr_len]);
+}
+
+static inline struct uip_ext_hdr *uip_ext_buf(void) {
+    return ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_ext_hdr *uip_first_ext_buf(void) {
+    return ((struct uip_ext_hdr *)&uip_buf[UIP_LLIPH_LEN]);
+}
+
+#define UIP_IP_BUF                (uip_ip_buf())
+#define UIP_ICMP_BUF            (uip_icmp_buf())
+#define UIP_ICMP6_ERROR_BUF  (uip_icmp6_error_buf())
+#define UIP_EXT_BUF              (uip_ext_buf())
+#define UIP_FIRST_EXT_BUF        (uip_first_ext_buf())

 /** \brief temporary IP address */
 static uip_ipaddr_t tmp_ipaddr;
@@ -409,7 +432,7 @@ UIP_ICMP6_HANDLER(echo_reply_handler, ICMP6_ECHO_REPLY,
                   UIP_ICMP6_HANDLER_CODE_ANY, echo_reply_input);
 /*---------------------------------------------------------------------------*/
 void
-uip_icmp6_init()
+uip_icmp6_init(void)
 {
   /* Register Echo Request and Reply handlers */
   uip_icmp6_register_input_handler(&echo_request_handler);
diff --git a/emb6/src/net/ipv6/uip-nd6.c b/emb6/src/net/ipv6/uip-nd6.c
index f04b6b3..26ed214 100644
--- a/emb6/src/net/ipv6/uip-nd6.c
+++ b/emb6/src/net/ipv6/uip-nd6.c
@@ -93,6 +93,37 @@ void uip_log(char *msg);
 #define UIP_LOG(m)
 #endif /* UIP_LOGGING == 1 */

+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+static inline struct uip_ip_hdr *uip_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])  /**< Pointer to IP header */;
+}
+
+static inline struct uip_icmp_hdr *uip_icmp_buf(void)
+{
+    return ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])  /**< Pointer to ICMP header*/;
+}
+
+static inline uip_nd6_rs *uip_nd6_rs_buf(void)
+{
+    return ((uip_nd6_rs *)&uip_buf[uip_l2_l3_icmp_hdr_len]);
+}
+
+static inline uip_nd6_ra *uip_nd6_ra_buf(void)
+{
+    return ((uip_nd6_ra *)&uip_buf[uip_l2_l3_icmp_hdr_len]);
+}
+
+static inline uip_nd6_ns *uip_nd6_ns_buf(void)
+{
+    return ((uip_nd6_ns *)&uip_buf[uip_l2_l3_icmp_hdr_len]);
+}
+
+static inline uip_nd6_na *uip_nd6_na_buf(void)
+{
+    return ((uip_nd6_na *)&uip_buf[uip_l2_l3_icmp_hdr_len]);
+}
+
 /*------------------------------------------------------------------*/
 /** @{ */
 /** \name Pointers to the header structures.
@@ -106,19 +137,19 @@ void uip_log(char *msg);
  *  value of these length variables
  */

-#define UIP_IP_BUF                ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])  /**< Pointer to IP header */
-#define UIP_ICMP_BUF            ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])  /**< Pointer to ICMP header*/
+#define UIP_IP_BUF                (uip_ip_buf())  /**< Pointer to IP header */
+#define UIP_ICMP_BUF            (uip_icmp_buf())  /**< Pointer to ICMP header*/
 /**@{  Pointers to messages just after icmp header */
-#define UIP_ND6_RS_BUF            ((uip_nd6_rs *)&uip_buf[uip_l2_l3_icmp_hdr_len])
-#define UIP_ND6_RA_BUF            ((uip_nd6_ra *)&uip_buf[uip_l2_l3_icmp_hdr_len])
-#define UIP_ND6_NS_BUF            ((uip_nd6_ns *)&uip_buf[uip_l2_l3_icmp_hdr_len])
-#define UIP_ND6_NA_BUF            ((uip_nd6_na *)&uip_buf[uip_l2_l3_icmp_hdr_len])
+#define UIP_ND6_RS_BUF            (uip_nd6_rs_buf())
+#define UIP_ND6_RA_BUF            (uip_nd6_ra_buf())
+#define UIP_ND6_NS_BUF            (uip_nd6_ns_buf())
+#define UIP_ND6_NA_BUF            (uip_nd6_na_buf())
 /** @} */
 /** Pointer to ND option */
-#define UIP_ND6_OPT_HDR_BUF  ((uip_nd6_opt_hdr *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
-#define UIP_ND6_OPT_PREFIX_BUF ((uip_nd6_opt_prefix_info *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
-#define UIP_ND6_OPT_MTU_BUF ((uip_nd6_opt_mtu *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
-#define UIP_ND6_OPT_RDNSS_BUF ((uip_nd6_opt_dns *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
+#define UIP_ND6_OPT_HDR_BUF  (uip_nd6_opt_hdr_buf())
+#define UIP_ND6_OPT_PREFIX_BUF (uip_nd6_opt_prefix_buf())
+#define UIP_ND6_OPT_MTU_BUF (uip_nd6_opt_mtu_buf())
+#define UIP_ND6_OPT_RDNSS_BUF (uip_nd6_opt_rdnss_buf())
 /** @} */

 static uint8_t nd6_opt_offset;                     /** Offset from the end of the icmpv6 header to the option in uip_buf*/
@@ -132,6 +163,27 @@ static uip_ds6_prefix_t *prefix; /**  Pointer to a prefix list entry */
 static uip_ds6_nbr_t *nbr; /**  Pointer to a nbr cache entry*/
 static uip_ds6_defrt_t *defrt; /**  Pointer to a router list entry */
 static uip_ds6_addr_t *addr; /**  Pointer to an interface address */
+
+static inline uip_nd6_opt_hdr *uip_nd6_opt_hdr_buf(void)
+{
+    return ((uip_nd6_opt_hdr *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset]);
+}
+
+static inline uip_nd6_opt_prefix_info *uip_nd6_opt_prefix_buf(void)
+{
+    return ((uip_nd6_opt_prefix_info *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset]);
+}
+
+static inline uip_nd6_opt_mtu *uip_nd6_opt_mtu_buf(void)
+{
+    return ((uip_nd6_opt_mtu *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset]);
+}
+
+static inline uip_nd6_opt_dns *uip_nd6_opt_rdnss_buf(void)
+{
+    return ((uip_nd6_opt_dns *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset]);
+}
+
 /*------------------------------------------------------------------*/
 /* create a llao */
 static void
@@ -1054,7 +1106,7 @@ UIP_ICMP6_HANDLER(ra_input_handler, ICMP6_RA, UIP_ICMP6_HANDLER_CODE_ANY,
 #endif
 /*---------------------------------------------------------------------------*/
 void
-uip_nd6_init()
+uip_nd6_init(void)
 {

 #if UIP_ND6_SEND_NA
diff --git a/emb6/src/net/ipv6/uip6.c b/emb6/src/net/ipv6/uip6.c
index 89edb73..281c8d9 100644
--- a/emb6/src/net/ipv6/uip6.c
+++ b/emb6/src/net/ipv6/uip6.c
@@ -152,6 +152,61 @@ uint8_t uip_ext_len = 0;
 uint8_t uip_ext_opt_offset = 0;
 /** @} */

+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+static inline struct uip_ip_hdr *uip_ip_buf(void) {
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+static inline struct uip_icmp_hdr *uip_icmp_buf(void) {
+    return ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_udp_hdr *uip_udp_buf(void) {
+    return ((struct uip_udp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN]);
+}
+
+static inline struct uip_tcp_hdr *uip_tcp_buf(void) {
+    return ((struct uip_tcp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN]);
+}
+
+static inline struct uip_ext_hdr *uip_ext_buf(void) {
+    return ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_routing_hdr *uip_routing_buf(void) {
+    return ((struct uip_routing_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_frag_hdr *uip_frag_buf(void) {
+    return ((struct uip_frag_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_hbho_hdr *uip_hbho_buf(void) {
+    return ((struct uip_hbho_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_desto_hdr *uip_desto_buf(void) {
+    return ((struct uip_desto_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_ext_hdr_opt *uip_ext_hdr_opt_buf(void) {
+    return ((struct uip_ext_hdr_opt *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]);
+}
+
+static inline struct uip_ext_hdr_opt_padn *uip_ext_hdr_opt_padn_buf(void) {
+    return ((struct uip_ext_hdr_opt_padn *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]);
+}
+
+#if UIP_CONF_IPV6_RPL
+static inline struct uip_ext_hdr_opt_rpl *uip_ext_hdr_opt_rpl_buf(void) {
+    return ((struct uip_ext_hdr_opt_rpl *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]);
+}
+#endif /* UIP_CONF_IPV6_RPL */
+
+static inline struct uip_icmp6_error *uip_icmp6_error_buf(void) {
+    return ((struct uip_icmp6_error *)&uip_buf[uip_l2_l3_icmp_hdr_len]);
+}
+
 /*---------------------------------------------------------------------------*/
 /* Buffers                                                                   */
 /*---------------------------------------------------------------------------*/
@@ -159,22 +214,22 @@ uint8_t uip_ext_opt_offset = 0;
  * \name Buffer defines
  *  @{
  */
-#define FBUF                             ((struct uip_tcpip_hdr *)&uip_reassbuf[0])
-#define UIP_IP_BUF                          ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
-#define UIP_ICMP_BUF                      ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_UDP_BUF                        ((struct uip_udp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
-#define UIP_TCP_BUF                        ((struct uip_tcp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
-#define UIP_EXT_BUF                        ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_ROUTING_BUF                ((struct uip_routing_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_FRAG_BUF                      ((struct uip_frag_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_HBHO_BUF                      ((struct uip_hbho_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_DESTO_BUF                    ((struct uip_desto_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_EXT_HDR_OPT_BUF            ((struct uip_ext_hdr_opt *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])
-#define UIP_EXT_HDR_OPT_PADN_BUF  ((struct uip_ext_hdr_opt_padn *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])
+#define FBUF                             (fbuf())
+#define UIP_IP_BUF                          (uip_ip_buf())
+#define UIP_ICMP_BUF                      (uip_icmp_buf())
+#define UIP_UDP_BUF                        (uip_udp_buf())
+#define UIP_TCP_BUF                        (uip_tcp_buf())
+#define UIP_EXT_BUF                        (uip_ext_buf())
+#define UIP_ROUTING_BUF                (uip_routing_buf())
+#define UIP_FRAG_BUF                      (uip_frag_buf())
+#define UIP_HBHO_BUF                      (uip_hbho_buf())
+#define UIP_DESTO_BUF                    (uip_desto_buf())
+#define UIP_EXT_HDR_OPT_BUF            (uip_ext_hdr_opt_buf())
+#define UIP_EXT_HDR_OPT_PADN_BUF  (uip_ext_hdr_opt_padn_buf())
 #if UIP_CONF_IPV6_RPL
-#define UIP_EXT_HDR_OPT_RPL_BUF    ((struct uip_ext_hdr_opt_rpl *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])
+#define UIP_EXT_HDR_OPT_RPL_BUF    (uip_ext_hdr_opt_rpl_buf())
 #endif /* UIP_CONF_IPV6_RPL */
-#define UIP_ICMP6_ERROR_BUF            ((struct uip_icmp6_error *)&uip_buf[uip_l2_l3_icmp_hdr_len])
+#define UIP_ICMP6_ERROR_BUF            (uip_icmp6_error_buf())
 /** @} */
 /**
  * \name Buffer variables
@@ -647,6 +702,9 @@ static uint8_t uip_reassflags;
 #define UIP_REASS_FLAG_FIRSTFRAG 0x02
 #define UIP_REASS_FLAG_ERROR_MSG 0x04

+static inline struct uip_tcpip_hdr *fbuf(void) {
+    return ((struct uip_tcpip_hdr *)&uip_reassbuf[0]);
+}

 /*
  * See RFC 2460 for a description of fragmentation in IPv6
diff --git a/emb6/src/net/rpl/rpl-ext-header.c b/emb6/src/net/rpl/rpl-ext-header.c
index 8bf1fe1..a680d52 100644
--- a/emb6/src/net/rpl/rpl-ext-header.c
+++ b/emb6/src/net/rpl/rpl-ext-header.c
@@ -56,13 +56,49 @@
 #include <string.h>

 /*---------------------------------------------------------------------------*/
-#define UIP_IP_BUF                ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
-#define UIP_EXT_BUF               ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_HBHO_BUF              ((struct uip_hbho_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_HBHO_NEXT_BUF         ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len + RPL_HOP_BY_HOP_LEN])
-#define UIP_EXT_HDR_OPT_BUF       ((struct uip_ext_hdr_opt *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])
-#define UIP_EXT_HDR_OPT_PADN_BUF  ((struct uip_ext_hdr_opt_padn *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])
-#define UIP_EXT_HDR_OPT_RPL_BUF   ((struct uip_ext_hdr_opt_rpl *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])
+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+static inline struct uip_ip_hdr *uip_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+static inline struct uip_ext_hdr *uip_ext_buf(void)
+{
+    return ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_hbho_hdr *uip_hbho_buf(void)
+{
+    return ((struct uip_hbho_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline struct uip_ext_hdr *uip_hbho_next_buf(void)
+{
+    return ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len + RPL_HOP_BY_HOP_LEN]);
+}
+
+static inline struct uip_ext_hdr_opt *uip_ext_hdr_opt_buf(int uip_ext_opt_offset)
+{
+    return ((struct uip_ext_hdr_opt *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]);
+}
+
+static inline struct uip_ext_hdr_opt_padn *uip_ext_hdr_opt_padn_buf(int uip_ext_opt_offset)
+{
+    return ((struct uip_ext_hdr_opt_padn *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]);
+}
+
+static inline struct uip_ext_hdr_opt_rpl *uip_ext_hdr_opt_rpl_buf(int uip_ext_opt_offset)
+{
+    return ((struct uip_ext_hdr_opt_rpl *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]);
+}
+
+#define UIP_IP_BUF                (uip_ip_buf())
+#define UIP_EXT_BUF               (uip_ext_buf())
+#define UIP_HBHO_BUF              (uip_hbho_buf())
+#define UIP_HBHO_NEXT_BUF         (uip_hbho_next_buf())
+#define UIP_EXT_HDR_OPT_BUF       (uip_ext_hdr_opt_buf(uip_ext_opt_offset))
+#define UIP_EXT_HDR_OPT_PADN_BUF  (uip_ext_hdr_opt_padn_buf(uip_ext_opt_offset))
+#define UIP_EXT_HDR_OPT_RPL_BUF   (uip_ext_hdr_opt_rpl_buf(uip_ext_opt_offset))
 /*---------------------------------------------------------------------------*/
 int
 rpl_verify_header(int uip_ext_opt_offset)
diff --git a/emb6/src/net/rpl/rpl-icmp6.c b/emb6/src/net/rpl/rpl-icmp6.c
index 0675e63..84eb5bd 100644
--- a/emb6/src/net/rpl/rpl-icmp6.c
+++ b/emb6/src/net/rpl/rpl-icmp6.c
@@ -68,9 +68,25 @@
 #define RPL_DIO_MOP_MASK                 0x38
 #define RPL_DIO_PREFERENCE_MASK          0x07

-#define UIP_IP_BUF       ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
-#define UIP_ICMP_BUF     ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
-#define UIP_ICMP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len])
+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+static inline struct uip_ip_hdr *uip_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+static inline struct uip_icmp_hdr *uip_icmp_buf(void)
+{
+    return ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len]);
+}
+
+static inline unsigned char *uip_icmp_payload(void)
+{
+    return ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len]);
+}
+
+#define UIP_IP_BUF       (uip_ip_buf())
+#define UIP_ICMP_BUF     (uip_icmp_buf())
+#define UIP_ICMP_PAYLOAD (uip_icmp_payload())
 /*---------------------------------------------------------------------------*/
 static void dis_input(void);
 static void dio_input(void);
@@ -950,7 +966,7 @@ dao_ack_output(rpl_instance_t *instance, uip_ipaddr_t *dest, uint8_t sequence)
 }
 /*---------------------------------------------------------------------------*/
 void
-rpl_icmp6_register_handlers()
+rpl_icmp6_register_handlers(void)
 {
     uip_icmp6_register_input_handler(&dis_handler);
     uip_icmp6_register_input_handler(&dio_handler);
diff --git a/emb6/src/net/sicslowpan/sicslowpan.c b/emb6/src/net/sicslowpan/sicslowpan.c
index 79afefe..529c6f4 100644
--- a/emb6/src/net/sicslowpan/sicslowpan.c
+++ b/emb6/src/net/sicslowpan/sicslowpan.c
@@ -161,13 +161,34 @@ void uip_log(char *msg);
 /** \name Pointers in the sicslowpan and uip buffer
  *  @{
  */
-#define SICSLOWPAN_IP_BUF   ((struct uip_ip_hdr *)&sicslowpan_buf[UIP_LLH_LEN])
-#define SICSLOWPAN_UDP_BUF ((struct uip_udp_hdr *)&sicslowpan_buf[UIP_LLIPH_LEN])
+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+struct uip_ip_hdr *uip_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+struct uip_udp_hdr *uip_udp_buf(void)
+{
+    return ((struct uip_udp_hdr *)&uip_buf[UIP_LLIPH_LEN]);
+}
+
+struct uip_tcp_hdr *uip_tcp_buf(void)
+{
+    return ((struct uip_tcp_hdr *)&uip_buf[UIP_LLIPH_LEN]);
+}
+
+struct uip_icmp_hdr *uip_icmp_buf(void)
+{
+    return ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN]);
+}
+
+#define SICSLOWPAN_IP_BUF   (sicslowpan_ip_buf())
+#define SICSLOWPAN_UDP_BUF (sicslowpan_udp_buf())

-#define UIP_IP_BUF          ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
-#define UIP_UDP_BUF          ((struct uip_udp_hdr *)&uip_buf[UIP_LLIPH_LEN])
-#define UIP_TCP_BUF          ((struct uip_tcp_hdr *)&uip_buf[UIP_LLIPH_LEN])
-#define UIP_ICMP_BUF          ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN])
+#define UIP_IP_BUF          (uip_ip_buf())
+#define UIP_UDP_BUF          (uip_udp_buf())
+#define UIP_TCP_BUF          (uip_tcp_buf())
+#define UIP_ICMP_BUF          (uip_icmp_buf())
 /** @} */


@@ -282,6 +303,16 @@ static s_ns_t*        p_ns = NULL;
 /*-------------------------------------------------------------------------*/
 static struct rime_sniffer *callback = NULL;

+struct uip_ip_hdr *sicslowpan_ip_buf(void)
+{
+    return ((struct uip_ip_hdr *)&sicslowpan_buf[UIP_LLH_LEN]);
+}
+
+struct uip_udp_hdr *sicslowpan_udp_buf(void)
+{
+    return ((struct uip_udp_hdr *)&sicslowpan_buf[UIP_LLIPH_LEN]);
+}
+
 void
 rime_sniffer_add(struct rime_sniffer *s)
 {
@@ -295,7 +326,7 @@ rime_sniffer_remove(struct rime_sniffer *s)
 }

 static void
-set_packet_attrs()
+set_packet_attrs(void)
 {
   int c = 0;
   /* set protocol in NETWORK_ID */
diff --git a/emb6/src/tport/udp-socket.c b/emb6/src/tport/udp-socket.c
index 545f6bd..3980716 100644
--- a/emb6/src/tport/udp-socket.c
+++ b/emb6/src/tport/udp-socket.c
@@ -44,7 +44,12 @@ void _udp_sock_callback(c_event_t c_event, p_data_t p_data);

 static uint8_t buf[UIP_BUFSIZE];

-#define UIP_IP_BUF   ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
+/* least intrusive way to prevent -Wstrict-aliasing from firing */
+static inline struct uip_udpip_hdr *uip_ip_buf(void) {
+    return ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN]);
+}
+
+#define UIP_IP_BUF   (uip_ip_buf())

 #define     LOGGER_ENABLE        LOGGER_CORE
 #if            LOGGER_ENABLE     ==     TRUE
--
1.9.1