From: bluhm Date: Sun, 31 May 2015 20:10:44 +0000 (+0000) Subject: If the first list was empty, ml_join() did not not clear the second X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7fb1b5fb8ba9047910f944576bd398e074d250ad;p=openbsd If the first list was empty, ml_join() did not not clear the second list after transferring all elements away. Reorder the conditionals to make sure that ml_init() is always called for a non empty second list. This makes all cases consistent and is less surprising. OK dlg@ --- diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 704bc98af1e..a230b8e3bcc 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.203 2015/04/13 08:45:48 mpi Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.204 2015/05/31 20:10:44 bluhm Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1266,10 +1266,11 @@ ml_enqueue(struct mbuf_list *ml, struct mbuf *m) void ml_join(struct mbuf_list *mla, struct mbuf_list *mlb) { - if (mla->ml_tail == NULL) - *mla = *mlb; - else if (mlb->ml_tail != NULL) { - mla->ml_tail->m_nextpkt = mlb->ml_head; + if (!ml_empty(mlb)) { + if (ml_empty(mla)) + mla->ml_head = mlb->ml_head; + else + mla->ml_tail->m_nextpkt = mlb->ml_head; mla->ml_tail = mlb->ml_tail; mla->ml_len += mlb->ml_len;