From owner-cvs-all Sat Sep 21 2:56:28 2002 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C13A237B401; Sat, 21 Sep 2002 02:56:26 -0700 (PDT) Received: from mta05ps.bigpond.com (mta05ps.bigpond.com [144.135.25.137]) by mx1.FreeBSD.org (Postfix) with ESMTP id ADA8E43E65; Sat, 21 Sep 2002 02:56:24 -0700 (PDT) (envelope-from darrenr@reed.wattle.id.au) Received: from CPE-61-9-164-106.vic.bigpond.net.au ([144.135.25.75]) by mta05ps.bigpond.com (Netscape Messaging Server 4.15 mta05ps Jul 16 2002 22:47:55) with SMTP id H2S8XX00.B50; Sat, 21 Sep 2002 19:56:21 +1000 Received: from CPE-203-51-143-15.vic.bigpond.net.au ([203.51.143.15]) by PSMAM03.mailsvc.email.bigpond.com(MailRouter V3.0n 89/13942087); 21 Sep 2002 19:56:21 Received: (from root@localhost) by CPE-61-9-164-106.vic.bigpond.net.au (8.11.0/8.11.0) id g8L9uMv06642; Sat, 21 Sep 2002 19:56:22 +1000 From: Darren Reed Message-Id: <200209210954.TAA28569@avalon.reed.wattle.id.au> Subject: Re: cvs commit: src/sys/kern uipc_mbuf.c In-Reply-To: <37234.1032598916@critter.freebsd.dk> To: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org Date: Sat, 21 Sep 2002 19:54:43 +1000 Cc: John@reed.wattle.id.au, Baldwin X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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