From d4a0b3f5bd1c165a1e5722475c41dc14d38baedd Mon Sep 17 00:00:00 2001 From: Oleg Hahm <oleg@hobbykeller.org> Date: Wed, 22 Jul 2015 14:38:28 +0200 Subject: [PATCH] gnrc: add some assertions --- sys/net/network_layer/ng_icmpv6/ng_icmpv6.c | 4 ++++ sys/net/network_layer/ng_ipv6/ng_ipv6.c | 2 ++ sys/net/transport_layer/ng_udp/ng_udp.c | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c b/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c index a27734fc00..9556076323 100644 --- a/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c +++ b/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c @@ -62,10 +62,14 @@ void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt) LL_SEARCH_SCALAR(pkt, icmpv6, type, NG_NETTYPE_ICMPV6); + assert(icmpv6 != NULL); + /* there can be extension headers between IPv6 and ICMPv6 header so we have * to search it */ LL_SEARCH_SCALAR(icmpv6, ipv6, type, NG_NETTYPE_IPV6); + assert(ipv6 != NULL); + hdr = (ng_icmpv6_hdr_t *)icmpv6->data; if (_calc_csum(icmpv6, ipv6, pkt)) { diff --git a/sys/net/network_layer/ng_ipv6/ng_ipv6.c b/sys/net/network_layer/ng_ipv6/ng_ipv6.c index 02f6f96a4f..328d7f5ebb 100644 --- a/sys/net/network_layer/ng_ipv6/ng_ipv6.c +++ b/sys/net/network_layer/ng_ipv6/ng_ipv6.c @@ -593,6 +593,8 @@ static void _receive(ng_pktsnip_t *pkt) ng_pktsnip_t *ipv6, *netif; ng_ipv6_hdr_t *hdr; + assert(pkt != NULL); + LL_SEARCH_SCALAR(pkt, netif, type, NG_NETTYPE_NETIF); if (netif != NULL) { diff --git a/sys/net/transport_layer/ng_udp/ng_udp.c b/sys/net/transport_layer/ng_udp/ng_udp.c index 6787d9bd0c..4e3f0ce27d 100644 --- a/sys/net/transport_layer/ng_udp/ng_udp.c +++ b/sys/net/transport_layer/ng_udp/ng_udp.c @@ -120,6 +120,8 @@ static void _receive(ng_pktsnip_t *pkt) LL_SEARCH_SCALAR(pkt, ipv6, type, NG_NETTYPE_IPV6); + assert(ipv6 != NULL); + /* validate checksum */ if (_calc_csum(udp, ipv6, pkt)) { DEBUG("udp: received packet with invalid checksum, dropping it\n"); @@ -144,6 +146,9 @@ static void _send(ng_pktsnip_t *pkt) /* get udp snip and hdr */ LL_SEARCH_SCALAR(pkt, udp_snip, type, NG_NETTYPE_UDP); + + assert(udp_snip != NULL); + udp_snip = ng_pktbuf_start_write(udp_snip); if (udp_snip == NULL) { DEBUG("udp: cannot send packet: unable to allocate packet\n"); -- GitLab