From 377f5ccbee6e9858adb9bb6baa5000d5d63cb671 Mon Sep 17 00:00:00 2001
From: Martine Lenders <mlenders@inf.fu-berlin.de>
Date: Sat, 25 Jul 2015 02:14:42 +0200
Subject: [PATCH] gnrc: replace ng_pktbuf_add() with ng_pktbuf_mark() where
 it's needed

---
 sys/net/application_layer/ng_zep/ng_zep.c                 | 8 ++++----
 sys/net/crosslayer/ng_pktbuf_static/ng_pktbuf_static.c    | 6 +++---
 sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c           | 2 +-
 sys/net/network_layer/ng_ipv6/ng_ipv6.c                   | 3 +--
 .../network_layer/ng_sixlowpan/iphc/ng_sixlowpan_iphc.c   | 2 +-
 sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c         | 3 +--
 sys/net/transport_layer/ng_udp/ng_udp.c                   | 2 +-
 7 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/sys/net/application_layer/ng_zep/ng_zep.c b/sys/net/application_layer/ng_zep/ng_zep.c
index 4b3a887440..4c53efd79c 100644
--- a/sys/net/application_layer/ng_zep/ng_zep.c
+++ b/sys/net/application_layer/ng_zep/ng_zep.c
@@ -728,7 +728,7 @@ static ng_pktsnip_t *_create_received(ng_zep_t *dev, ng_pktsnip_t *pkt,
         return NULL;
     }
 
-    payload = ng_pktbuf_add(pkt, pkt->data, pkt->size - 2, dev->proto);
+    payload = ng_pktbuf_mark(pkt, pkt->size - 2, dev->proto);
 
     if (payload == NULL) {
         return NULL;
@@ -742,7 +742,7 @@ static ng_pktsnip_t *_create_received(ng_zep_t *dev, ng_pktsnip_t *pkt,
         return NULL;
     }
 
-    mhr = ng_pktbuf_add(pkt, pkt->data, mhr_len, NG_NETTYPE_UNDEF);
+    mhr = ng_pktbuf_mark(pkt, mhr_len, NG_NETTYPE_UNDEF);
 
     /* TODO: send ACK */
 
@@ -776,7 +776,7 @@ static ng_pktsnip_t *_recv_v1(ng_zep_t *dev, ng_pktsnip_t *pkt)
         return NULL;
     }
 
-    zep = ng_pktbuf_add(pkt, pkt->data, sizeof(ng_zep_v1_hdr_t), NG_NETTYPE_UNDEF);
+    zep = ng_pktbuf_mark(pkt, sizeof(ng_zep_v1_hdr_t), NG_NETTYPE_UNDEF);
 
     if (zep == NULL) {
         return NULL;
@@ -807,7 +807,7 @@ static ng_pktsnip_t *_recv_v2(ng_zep_t *dev, ng_pktsnip_t *pkt)
             return NULL;
         }
 
-        zep = ng_pktbuf_add(pkt, pkt->data, sizeof(ng_zep_v2_data_hdr_t), NG_NETTYPE_UNDEF);
+        zep = ng_pktbuf_mark(pkt, sizeof(ng_zep_v2_data_hdr_t), NG_NETTYPE_UNDEF);
 
         if (zep == NULL) {
             return NULL;
diff --git a/sys/net/crosslayer/ng_pktbuf_static/ng_pktbuf_static.c b/sys/net/crosslayer/ng_pktbuf_static/ng_pktbuf_static.c
index 88f9b8b95e..6c520b622b 100644
--- a/sys/net/crosslayer/ng_pktbuf_static/ng_pktbuf_static.c
+++ b/sys/net/crosslayer/ng_pktbuf_static/ng_pktbuf_static.c
@@ -235,7 +235,7 @@ ng_pktsnip_t *ng_pktbuf_start_write(ng_pktsnip_t *pkt)
 
 #ifdef DEVELHELP
 #ifdef MODULE_OD
-void _print_chunk(void *chunk, size_t size, int num)
+static inline void _print_chunk(void *chunk, size_t size, int num)
 {
     printf("================ chunk %3d (size: %4u) ================\n", num,
            (unsigned int)size);
@@ -243,7 +243,7 @@ void _print_chunk(void *chunk, size_t size, int num)
        OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1);
 }
 
-void _print_unused(_unused_t *ptr)
+static inline void _print_unused(_unused_t *ptr)
 {
     printf("~ unused: %p (next: %p, size: %4u) ~\n", (void *)ptr,
            (void *)ptr->next, ptr->size);
@@ -283,7 +283,7 @@ void ng_pktbuf_stats(void)
     }
 
     if (chunk <= &_pktbuf[NG_PKTBUF_SIZE - 1]) {
-        _print_chunk(chunk, &_pktbuf[NG_PKTBUF_SIZE] - chunk, count++);
+        _print_chunk(chunk, &_pktbuf[NG_PKTBUF_SIZE] - chunk, count);
     }
 #else
     DEBUG("pktbuf: needs od module\n");
diff --git a/sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c b/sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c
index 1f746e0ad0..f1b6ef9540 100644
--- a/sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c
+++ b/sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c
@@ -54,7 +54,7 @@ bool ng_ipv6_ext_demux(kernel_pid_t iface, ng_pktsnip_t *pkt,
         }
     }
 
-    ext_snip = ng_pktbuf_add(pkt, pkt->data, offset, NG_NETTYPE_IPV6);
+    ext_snip = ng_pktbuf_mark(pkt, offset, NG_NETTYPE_IPV6);
 
     if (ext_snip == NULL) {
         return false;
diff --git a/sys/net/network_layer/ng_ipv6/ng_ipv6.c b/sys/net/network_layer/ng_ipv6/ng_ipv6.c
index 328d7f5ebb..5deee0c335 100644
--- a/sys/net/network_layer/ng_ipv6/ng_ipv6.c
+++ b/sys/net/network_layer/ng_ipv6/ng_ipv6.c
@@ -630,8 +630,7 @@ static void _receive(ng_pktsnip_t *pkt)
 
         pkt = ipv6;     /* reset pkt from temporary variable */
 
-        ipv6 = ng_pktbuf_add(pkt, pkt->data, sizeof(ng_ipv6_hdr_t),
-                             NG_NETTYPE_IPV6);
+        ipv6 = ng_pktbuf_mark(pkt, sizeof(ng_ipv6_hdr_t), NG_NETTYPE_IPV6);
 
         if (ipv6 == NULL) {
             DEBUG("ipv6: error marking IPv6 header, dropping packet\n");
diff --git a/sys/net/network_layer/ng_sixlowpan/iphc/ng_sixlowpan_iphc.c b/sys/net/network_layer/ng_sixlowpan/iphc/ng_sixlowpan_iphc.c
index eb29da9a89..9fe0043f4d 100644
--- a/sys/net/network_layer/ng_sixlowpan/iphc/ng_sixlowpan_iphc.c
+++ b/sys/net/network_layer/ng_sixlowpan/iphc/ng_sixlowpan_iphc.c
@@ -369,7 +369,7 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
     /* TODO: add next header decoding */
 
     /* remove 6LoWPAN dispatch */
-    payload = ng_pktbuf_add(pkt, pkt->data, payload_offset, NG_NETTYPE_SIXLOWPAN);
+    payload = ng_pktbuf_mark(pkt, payload_offset, NG_NETTYPE_SIXLOWPAN);
     pkt = ng_pktbuf_remove_snip(pkt, payload);
 
     /* set IPv6 header payload length field to the length of whatever is left
diff --git a/sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c b/sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c
index f2c60f199e..2cfa09986b 100644
--- a/sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c
+++ b/sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c
@@ -103,8 +103,7 @@ static void _receive(ng_pktsnip_t *pkt)
         }
 
         /* packet is uncompressed: just mark and remove the dispatch */
-        sixlowpan = ng_pktbuf_add(payload, payload->data, sizeof(uint8_t),
-                                  NG_NETTYPE_SIXLOWPAN);
+        sixlowpan = ng_pktbuf_mark(payload, sizeof(uint8_t), NG_NETTYPE_SIXLOWPAN);
 
         if (sixlowpan == NULL) {
             DEBUG("6lo: can not mark 6LoWPAN dispatch\n");
diff --git a/sys/net/transport_layer/ng_udp/ng_udp.c b/sys/net/transport_layer/ng_udp/ng_udp.c
index 4e3f0ce27d..5910bf19c3 100644
--- a/sys/net/transport_layer/ng_udp/ng_udp.c
+++ b/sys/net/transport_layer/ng_udp/ng_udp.c
@@ -107,7 +107,7 @@ static void _receive(ng_pktsnip_t *pkt)
         return;
     }
     pkt = udp;
-    udp = ng_pktbuf_add(pkt, pkt->data, sizeof(ng_udp_hdr_t), NG_NETTYPE_UDP);
+    udp = ng_pktbuf_mark(pkt, sizeof(ng_udp_hdr_t), NG_NETTYPE_UDP);
     if (udp == NULL) {
         DEBUG("udp: error marking UDP header, dropping packet\n");
         ng_pktbuf_release(pkt);
-- 
GitLab