Date: Sat, 21 Sep 2002 10:10:00 -0700 From: "Sam Leffler" <sam@errno.com> To: "Julian Elischer" <julian@elischer.org>, "John Baldwin" <jhb@FreeBSD.org> Cc: "Darren Reed" <darrenr@reed.wattle.id.au>, <cvs-all@FreeBSD.org>, <cvs-committers@FreeBSD.org> Subject: Re: cvs commit: src/sys/kern uipc_mbuf.c Message-ID: <112201c26191$b8ddefe0$52557f42@errno.com> References: <Pine.BSF.4.21.0209201236320.16925-100000@InterJet.elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Fri, 20 Sep 2002, John Baldwin wrote: > > > > > On 20-Sep-2002 Darren Reed wrote: > > > btw, I think m_length() as a function which does something besides return > > > the length of an mbuf is wrong. I think that kind of task is better delt > > > with by keeping a pointer to the last mbuf in the chain. I'd recommend > > > that m_length() do what it suggests it do and have another one, m_lastbuf() > > > or something to do that job. Well, no, needing m_lastbuf() just sucks > > > bigtime. Some thought to making m_length() a M_LENGTH() might be an idea > > > too (that thought crossed my mind elsewhere), but that'd only fit well if > > > mbufs were fixed up with a tail pointer. > > > > FWIW, I agree with this. If the function name needs to be changed to > > make it more intuitive, so be it. There is nothing intuitive about > > a function named foo_length() not returning the length of 'foo'. > > > > m_iterate() > There is already an m_apply routine in other systems (I pulled in a copy for crypto use): /* * Apply function f to the data in an mbuf chain starting "off" bytes from the * beginning, continuing for "len" bytes. */ extern int m_apply(struct mbuf *m, int off, int len, int (*f)(caddr_t, caddr_t, unsigned int), caddr_t fstate); (and please no comments about caddr_t use). Similarly, a more general alternative to m_length returning a pointer to the last mbuf is m_getptr that takes an mbuf pointer and an offset (in bytes) and returns a pointer to the mbuf that holds data at that offset into the packet and, optionally, a byte offset within that mbuf. struct mbuf *m_getptr(struct mbuf *, int, int *); Rather than haphazardly sticking in new mbuf routines it would be good if *bsd could standardize on some set of base set of routines to improve code portability. At the very least it'd be good to try and add compatible interfaces when trying to replace redundant code with a core routine. Sam 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?112201c26191$b8ddefe0$52557f42>