Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Sep 2002 19:54:43 +1000
From:      Darren Reed <darrenr@reed.wattle.id.au>
To:        cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org
Cc:        John@reed.wattle.id.au, Baldwin <jhb@FreeBSD.org>
Subject:   Re: cvs commit: src/sys/kern uipc_mbuf.c
Message-ID:  <200209210954.TAA28569@avalon.reed.wattle.id.au>
In-Reply-To: <37234.1032598916@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
In some email I received from Poul-Henning Kamp, sie wrote:
> Darren,
> 
> You don't seem to understand that this function is (should only be)
> used in cases where m_pkthdr.len cannot be used and that the only
> possible way to find the length in those cases is to traverse the
> chain.

So, explain to me why you've patched code to use m_length() in all
those places where m_pkthdr.len can be used and walking the chain
is a last-resort with no tail pointer is required.

> If you feel it is important to be able to use m_pkthdr.len in all
> cases, feel free to change the code which calls m_length() to be
> able to do this instead of calling m_length().

I think it should not use m_length() at all if you don't want to
rename m_length() or fix it so it works quicker for the most common
case.

That said, would anyone object to me adding the macro below to FreeBSD
in sys/mbuf.h ?  It's a tad gross because of the local variables :/

Darren


/*
 * MLENGTH(int len, struct mbuf *m)
 * Computes the length of the mbuf chain (m) and stores in an integer (len)
 */
#define	MLENGTH(l,m)							\
do {									\
	if (((m)->m_pkthdr.flags & M_PKTHDR) != 0)			\
		(l) = (m)->m_pkthdr.len;				\
	else {								\
		struct mbuf *_m;					\
		int _l;							\
									\
		for (_l = 0; _m = (m); _m != NULL; _m = _m->m_next)	\
			_l += m->m_len;					\
		(l) = _l;						\
	}								\
} while (/* CONSTCOND */ 0)


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209210954.TAA28569>