Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/sys/dev/usb
On Sat, Apr 21, 2018 at 09:37:46AM +0200, Martin Husemann wrote:
> On Sat, Apr 21, 2018 at 09:30:20AM +0200, Manuel Bouyer wrote:
> > > >
> > > >- axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, (void *)&hashtbl);
> > > >+ axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, hashtbl);
> > > >
> > > >missing & ?
> > >
> > > uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
> >
> > So I guess the code was wrong before; not sure how multicast could have
> > worked.
>
> No, the address is only needed as rhs of the cast. If passed directly,
> the address will be used (due to arrays being passed as pointer to first
> element in C).
>
> Try it:
>
> #include <stdio.h>
> #include <inttypes.h>
>
> int main(void)
> {
> static uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
>
> printf("%p vs %p\n", (void *)&hashtbl, hashtbl);
> return 0;
> }
I didn't know this. hashtbl and &hashtbl[0] are equivalent, and I would
assume that &hashtbl is always a pointer to pointer. So the behavior depends
on hashtbl being declared as pointer or as array ?
this is confusing ...
--
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
NetBSD: 26 ans d'experience feront toujours la difference
--
Home |
Main Index |
Thread Index |
Old Index