From owner-freebsd-net Sat Jun 1 14:15: 7 2002 Delivered-To: freebsd-net@freebsd.org Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by hub.freebsd.org (Postfix) with ESMTP id 0181737B401 for ; Sat, 1 Jun 2002 14:15:03 -0700 (PDT) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id OAA65988; Sat, 1 Jun 2002 14:09:41 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g51L8f608736; Sat, 1 Jun 2002 14:08:41 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200206012108.g51L8f608736@arch20m.dellroad.org> Subject: Re: m_split() considered harmful In-Reply-To: <20020602004417.H2786-100000@gamplex.bde.org> "from Bruce Evans at Jun 2, 2002 00:51:56 am" To: Bruce Evans Date: Sat, 1 Jun 2002 14:08:41 -0700 (PDT) Cc: Archie Cobbs , Julian Elischer , Bosko Milekic , freebsd-net@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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