1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-16 10:03:50 +01:00

Merge pull request #18874 from maribu/sys/net/gnrc/pkt

sys/net/gnrc/pkt: fix gnrc_pkt_delete()
This commit is contained in:
Marian Buschsieweke 2022-11-11 09:21:25 +01:00 committed by GitHub
commit 4166e044b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,10 +210,26 @@ static inline gnrc_pktsnip_t *gnrc_pkt_prepend(gnrc_pktsnip_t *pkt,
static inline gnrc_pktsnip_t *gnrc_pkt_delete(gnrc_pktsnip_t *pkt,
gnrc_pktsnip_t *snip)
{
list_node_t list = { (list_node_t *)pkt };
/* Removing head is a no-op. The new head is the next in the list. */
if (pkt == snip) {
return pkt->next;
}
list_remove(&list, (list_node_t *)snip);
return (gnrc_pktsnip_t *)list.next;
/* Removing nothing is a no-op, the new head is the old one */
if (snip == NULL) {
return pkt;
}
/* Iterate over the list and remove the given snip from it, if found.
* The new head is the old head. */
for (gnrc_pktsnip_t *i = pkt; i != NULL; i = i->next) {
if (i->next == snip) {
i->next = snip->next;
return pkt;
}
}
return pkt;
}
/**