Browse Source

gnrc: cleanup and corrections in gnrc_pkt

master
smlng 6 years ago
parent
commit
d11754031a
  1. 6
      sys/include/net/gnrc/pkt.h
  2. 15
      sys/net/gnrc/pkt/gnrc_pkt.c

6
sys/include/net/gnrc/pkt.h

@ -128,7 +128,7 @@ static inline size_t gnrc_pkt_len(gnrc_pktsnip_t *pkt)
{
size_t len = 0;
while (pkt) {
while (pkt != NULL) {
len += pkt->size;
pkt = pkt->next;
}
@ -148,7 +148,7 @@ static inline size_t gnrc_pkt_len_upto(gnrc_pktsnip_t *pkt, gnrc_nettype_t type)
{
size_t len = 0;
while (pkt) {
while (pkt != NULL) {
len += pkt->size;
if (pkt->type == type) {
@ -172,7 +172,7 @@ static inline size_t gnrc_pkt_count(const gnrc_pktsnip_t *pkt)
{
size_t count = 0;
while (pkt) {
while (pkt != NULL) {
++count;
pkt = pkt->next;
}

15
sys/net/gnrc/pkt/gnrc_pkt.c

@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Freie Universität Berlin
* 2017 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
@ -11,22 +12,18 @@
*
* @file
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/
#include <assert.h>
#include "net/gnrc/pkt.h"
gnrc_pktsnip_t *gnrc_pktsnip_search_type(gnrc_pktsnip_t *ptr,
gnrc_pktsnip_t *gnrc_pktsnip_search_type(gnrc_pktsnip_t *pkt,
gnrc_nettype_t type)
{
while (ptr != NULL) {
if (ptr->type == type) {
return ptr;
}
ptr = ptr->next;
while ((pkt != NULL) && (pkt->type != type)) {
pkt = pkt->next;
}
return NULL;
return pkt;
}
/** @} */

Loading…
Cancel
Save