git: a43fb3653b35 - main - mbuf: improve KASSERT(9) falure messages in the m_apply()

From: Maxim Sobolev <sobomax_at_FreeBSD.org>
Date: Tue, 10 Sep 2024 02:31:24 UTC
The branch main has been updated by sobomax:

URL: https://cgit.FreeBSD.org/src/commit/?id=a43fb3653b35ab88b72e1277dccc26328363cdb7

commit a43fb3653b35ab88b72e1277dccc26328363cdb7
Author:     Maxim Sobolev <sobomax@FreeBSD.org>
AuthorDate: 2024-09-10 01:51:05 +0000
Commit:     Maxim Sobolev <sobomax@FreeBSD.org>
CommitDate: 2024-09-10 02:30:28 +0000

    mbuf: improve KASSERT(9) falure messages in the m_apply()
    
    - Make less ambiguous;
    - extend to provide more context for post-mortem.
    
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D43776
    MFC after:      2 weeks
---
 sys/kern/uipc_mbuf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index d6b38cf8fbc8..f6ce9b5cc74b 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1439,14 +1439,16 @@ m_apply(struct mbuf *m, int off, int len,
 	KASSERT(off >= 0, ("m_apply, negative off %d", off));
 	KASSERT(len >= 0, ("m_apply, negative len %d", len));
 	while (off > 0) {
-		KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain"));
+		KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain "
+		    "(%d extra)", off));
 		if (off < m->m_len)
 			break;
 		off -= m->m_len;
 		m = m->m_next;
 	}
 	while (len > 0) {
-		KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain"));
+		KASSERT(m != NULL, ("m_apply, length > size of mbuf chain "
+		    "(%d extra)", len));
 		count = min(m->m_len - off, len);
 		rval = m_apply_one(m, off, count, f, arg);
 		if (rval)