Thread (6 messages) flat view 6 messages, 3 authors, 2003-08-18

Re: double-check me?

From: Jason Lunz <hidden>
Date: 2003-08-17 21:34:22

jgarzik@pobox.com said:
         if (sizeof_priv)
                 dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);


Now... shouldn't that last line of code be "dev + 1 + sizeof(*dev)" ?
are you missing that the "dev + 1" pointer arithmetic is already adding
sizeof(*dev) to dev, rather than just 1 byte? "(dev + 1)" is a pointer
to the private area after the actual struct net_device, and
"((long)(dev + 1) + 31)" adds 31 bytes of padding. The final "& ~31"
chops off any excess padding from the 31 that was added and actually
aligns the pointer.

Seems right to me, but I'm not used to playing alignment tricks.

Jason
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help