Date: Wed, 22 Apr 1998 10:06:15 -0500 (CDT) From: Alex Nash <nash@Mcs.Net> To: Jim Lowe <james@miller.cs.uwm.edu> Cc: freebsd-bugs@FreeBSD.ORG, jwd@unx.sas.com Subject: Re: PCI attach of if_ed.c & if_lnc.c Message-ID: <Pine.BSF.3.95.980422100256.3034B-100000@Jupiter.Mcs.Net> In-Reply-To: <199804221408.JAA07541@miller.cs.uwm.edu>
index | next in thread | previous in thread | raw e-mail
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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.980422100256.3034B-100000>
