diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-03 18:39:57 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-03 18:39:57 +0000 |
commit | 3c06cae61abedff44f961de3bea1f802e150b7d0 (patch) | |
tree | 9d9f67957bfae6228f243ea815cdcbbe60c0db9b /sys/kern/uipc_mbuf2.c | |
parent | d8ed1054415585ff91573c64d88c0c2a67483a28 (diff) |
Remove two "unused" mbuf tag functions and kill the superfluous argument
to the m_tag_delete_chain() function.
m_tag_free() and m_tag_unlink() are only used by m_tag_delete() and I see
no need to have these functions around.
m_tag_delete_chain() has a second argument to specifiy a starting point
from where the chain should be deleted. This feature is never used and is
more complex because it is not possible to remove a SLIST element without
doing a list walk. Instead use SLIST_FIRST() and SLIST_REMOVE_HEAD() to
remove all items from the list. OK dhartmei@
Diffstat (limited to 'sys/kern/uipc_mbuf2.c')
-rw-r--r-- | sys/kern/uipc_mbuf2.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c index dce50e93814..68c10a969d5 100644 --- a/sys/kern/uipc_mbuf2.c +++ b/sys/kern/uipc_mbuf2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf2.c,v 1.25 2006/11/18 08:20:51 jmc Exp $ */ +/* $OpenBSD: uipc_mbuf2.c,v 1.26 2007/01/03 18:39:56 claudio Exp $ */ /* $KAME: uipc_mbuf2.c,v 1.29 2001/02/14 13:42:10 itojun Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */ @@ -273,13 +273,6 @@ m_tag_get(int type, int len, int wait) return (t); } -/* Free a packet tag. */ -void -m_tag_free(struct m_tag *t) -{ - free(t, M_PACKET_TAGS); -} - /* Prepend a packet tag. */ void m_tag_prepend(struct mbuf *m, struct m_tag *t) @@ -287,36 +280,24 @@ m_tag_prepend(struct mbuf *m, struct m_tag *t) SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link); } -/* Unlink a packet tag. */ -void -m_tag_unlink(struct mbuf *m, struct m_tag *t) -{ - SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link); -} - /* Unlink and free a packet tag. */ void m_tag_delete(struct mbuf *m, struct m_tag *t) { - m_tag_unlink(m, t); - m_tag_free(t); + SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link); + free(t, M_PACKET_TAGS); } -/* Unlink and free a packet tag chain, starting from given tag. */ +/* Unlink and free a packet tag chain. */ void -m_tag_delete_chain(struct mbuf *m, struct m_tag *t) +m_tag_delete_chain(struct mbuf *m) { - struct m_tag *p, *q; + struct m_tag *p; - if (t != NULL) - p = t; - else - p = SLIST_FIRST(&m->m_pkthdr.tags); - if (p == NULL) - return; - while ((q = SLIST_NEXT(p, m_tag_link)) != NULL) - m_tag_delete(m, q); - m_tag_delete(m, p); + while ((p = SLIST_FIRST(&m->m_pkthdr.tags)) != NULL) { + SLIST_REMOVE_HEAD(&m->m_pkthdr.tags, m_tag_link); + free(p, M_PACKET_TAGS); + } } /* Find a tag, starting from a given position. */ @@ -361,11 +342,11 @@ m_tag_copy_chain(struct mbuf *to, struct mbuf *from) { struct m_tag *p, *t, *tprev = NULL; - m_tag_delete_chain(to, NULL); + m_tag_delete_chain(to); SLIST_FOREACH(p, &from->m_pkthdr.tags, m_tag_link) { t = m_tag_copy(p); if (t == NULL) { - m_tag_delete_chain(to, NULL); + m_tag_delete_chain(to); return (0); } if (tprev == NULL) |