Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Jun 2002 14:08:41 -0700 (PDT)
From:      Archie Cobbs <archie@dellroad.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Archie Cobbs <archie@dellroad.org>, Julian Elischer <julian@elischer.org>, Bosko Milekic <bmilekic@unixdaemons.com>, freebsd-net@FreeBSD.ORG
Subject:   Re: m_split() considered harmful
Message-ID:  <200206012108.g51L8f608736@arch20m.dellroad.org>
In-Reply-To: <20020602004417.H2786-100000@gamplex.bde.org> "from Bruce Evans at Jun 2, 2002 00:51:56 am"

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans writes:
> > That is, what we really need is a more general audit for code that
> > writes into mbufs that might be read-only -- and, as one special case
> > of tha, code that calls M_TRAILINGSPACE()/M_LEADINGSPACE() before writing
> > into an mbuf.
> >
> > FYI, any easy way to do this would be to add const'ness to mtod():
> >
> >     #define mtod(m, t)  ((const t)((m)->m_data))
> >
> > and then look for GCC warnings. Any takers?? :-)
> 
> This assumes that t is literally a pointer.  When t is caddr_t,
> `const t' is a const variable which (if caddr_t is `char *') is a
> pointer to non-const storage, but you want a non-const pointer to
> const storage.

Yep, you are right about that case... (as usual :-)

-Archie

__________________________________________________________________________
Archie Cobbs     *     Packet Design     *     http://www.packetdesign.com

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




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