From owner-freebsd-bugs Wed Apr 22 08:06:20 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA28035 for freebsd-bugs-outgoing; Wed, 22 Apr 1998 08:06:20 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from Kitten.mcs.com (Kitten.mcs.com [192.160.127.90]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA28009 for ; Wed, 22 Apr 1998 15:06:16 GMT (envelope-from nash@Jupiter.Mcs.Net) Received: from Jupiter.Mcs.Net (nash@Jupiter.mcs.net [192.160.127.88]) by Kitten.mcs.com (8.8.7/8.8.2) with ESMTP id KAA07846; Wed, 22 Apr 1998 10:06:15 -0500 (CDT) Received: from localhost (nash@localhost) by Jupiter.Mcs.Net (8.8.7/8.8.2) with SMTP id KAA04416; Wed, 22 Apr 1998 10:06:15 -0500 (CDT) Date: Wed, 22 Apr 1998 10:06:15 -0500 (CDT) From: Alex Nash To: Jim Lowe cc: freebsd-bugs@FreeBSD.ORG, jwd@unx.sas.com Subject: Re: PCI attach of if_ed.c & if_lnc.c In-Reply-To: <199804221408.JAA07541@miller.cs.uwm.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Wed, 22 Apr 1998, Jim Lowe wrote: > I was having some trouble with attaching PCI versions of the Lance > ethernet driver (it is crashing my system). I looked at the code > and in if_lnc.c and there seems to be a problem. A similar problem > exists in the if_ed.c driver. [...] > if_lnc.c: > struct lnc_softc *sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT); > if (sc) > bzero(sc, sizeof *sc); > [...] [...] > Shouldn't these routines be allocating and clearing the softc structure > and not a pointer to the softc structure as below? > > if_lnc.c: > struct lnc_softc *sc = malloc(sizeof sc, M_DEVBUF, M_NOWAIT); > if (sc) > bzero(sc, sizeof sc); No. sizeof(sc) equates to the size of a pointer, not the size of the item pointed to by the pointer (*sc). In other words: sizeof(sc) = size of the pointer, in this case 4 bytes sizeof(*sc) = size of the softc structure (whatever that is) Alex To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message