cvs commit: src/sys/conf options src/sys/netinet ip_output.c
Eivind Eklund
eivind at FreeBSD.org
Wed Mar 26 14:37:15 PST 2003
On Tue, Mar 25, 2003 at 11:20:16PM +0100, Maxime Henrion wrote:
> I think we should have some code like this before handing a packet to a
> network driver :
>
> KASSERT(m0->m_pkthdr.len == m_length(m0, NULL), ("Bad packet header"));
This is a structure invariant check, and I'm strongly in favour of those -
however, I'd prefer if the logic for the invariant itself was located in
only one place.
Ie, define in a header (use of inline function instead of #define to avoid
problems with multiple evaluation of m):
static inline mbuf_invariant(struct mbuf *m) {
return m->m.pkthdr.len == m_length(m, NULL);
}
then do
KASSERT(mbuf_invariant(m), ("Bad packet header");
Eivind.
More information about the cvs-src
mailing list