From owner-freebsd-net Wed Nov 28 2: 0:51 2001 Delivered-To: freebsd-net@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id 50A2B37B405; Wed, 28 Nov 2001 02:00:26 -0800 (PST) Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id BAA13886; Wed, 28 Nov 2001 01:46:16 -0800 (PST) Date: Wed, 28 Nov 2001 01:46:14 -0800 (PST) From: Julian Elischer To: Luigi Rizzo Cc: "Andrew R. Reiter" , "Bruce A. Mah" , freebsd-net@FreeBSD.ORG Subject: Re: RFC: MFC M_ZERO usage for bpf.c In-Reply-To: <20011127115755.A1151@iguana.aciri.org> Message-ID: MIME-Version: 1.0 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 On Tue, 27 Nov 2001, Luigi Rizzo wrote: > On Tue, Nov 27, 2001 at 02:52:49PM -0500, Andrew R. Reiter wrote: > > > > Just as a note, I decided against MFC'ing this and similar changes because > > I didn't feel it was necesary for -STABLE to have this "fix." > > why not ? code is more compact (and cache friendly) and readable, > diffs from HEAD are reduced, no functional changes... I see only > good things in these MFCs. > > While we are on the topic, I would also love to see more consistency > in the use of macros vs. inline functions. E.g. below we have > > MALLOC(d, struct bpf_d *, sizeof(*d), M_BPF, M_WAITOK | M_ZERO); > > and > > bp = (struct bpf_if *)malloc(sizeof(*bp), M_BPF, M_DONTWAIT | M_ZERO); > why cast the thing? it returns a void * which obviates the need for any casting.... > and the same occurs elsewhere for free() and FREE(). This is confusing > because it leads you into thinking that they are two different things > while they are not. > > cheers > luigi > > > On Tue, 27 Nov 2001, Bruce A. Mah wrote: > > > > :Hi-- > > : > > :I've been reading through src/sys/net/bpf.c, and I noticed that the > > :changes to make it use M_ZERO haven't been MFC-ed to RELENG_4 yet. Any > > :objection if I do this? (Nothing broke in my quick testing.) > > : > > :Thanks, > > : > > :Bruce. > > : > > :Index: bpf.c > > :=================================================================== > > :RCS file: /usr/ncvs/src/sys/net/bpf.c,v > > :retrieving revision 1.59.2.6 > > :diff -u -r1.59.2.6 bpf.c > > :--- bpf.c 20 Sep 2001 14:31:33 -0000 1.59.2.6 > > :+++ bpf.c 27 Nov 2001 18:49:45 -0000 > > :@@ -358,8 +358,7 @@ > > : if (d) > > : return (EBUSY); > > : make_dev(&bpf_cdevsw, minor(dev), 0, 0, 0600, "bpf%d", lminor(dev)); > > :- MALLOC(d, struct bpf_d *, sizeof(*d), M_BPF, M_WAITOK); > > :- bzero(d, sizeof(*d)); > > :+ MALLOC(d, struct bpf_d *, sizeof(*d), M_BPF, M_WAITOK | M_ZERO); > > : dev->si_drv1 = d; > > : d->bd_bufsize = bpf_bufsize; > > : d->bd_sig = SIGIO; > > :@@ -1285,11 +1284,10 @@ > > : u_int dlt, hdrlen; > > : { > > : struct bpf_if *bp; > > :- bp = (struct bpf_if *)malloc(sizeof(*bp), M_BPF, M_DONTWAIT); > > :+ bp = (struct bpf_if *)malloc(sizeof(*bp), M_BPF, M_DONTWAIT | M_ZERO); > > : if (bp == 0) > > : panic("bpfattach"); > > : > > :- bp->bif_dlist = 0; > > : bp->bif_ifp = ifp; > > : bp->bif_dlt = dlt; > > : > > : > > : > > : > > > > -- > > Andrew R. Reiter > > arr@watson.org > > arr@FreeBSD.org > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-net" in the body of the message > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-net" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message