[openib-general] Re: [PATCH] SDP: use container_of in place of cast to sdp_opt

Libor Michalek libor at topspin.com
Tue Jun 21 10:54:46 PDT 2005


On Tue, Jun 21, 2005 at 08:35:15PM +0300, Michael S. Tsirkin wrote:
> Quoting r. Tom Duffy <tduffy at sun.com>:
> > Subject: Re: [PATCH] SDP: use container_of in place of cast to sdp_opt
> > 
> > On Tue, 2005-06-21 at 09:21 +0300, Michael S. Tsirkin wrote:
> > > As a side note, wouldnt sk_to_sdp and sdp_to_sk be better names for
> > > sdp_sk and sk_sdp?
> > 
> > I modeled this code based off of every other socket class in Linux.
> > They use casts and shortened names.
> 
> Seems to be not entirely accurate: there is inet_sk but I no sk_inet
> that I could see. And inet_sk() kind of makes sense since it returns
> inet_socket, as opposed to sdp_sk() which returns sdp_conn :)
> 
> As for casts, inet_sock says:
>         /* sk and pinet6 has to be the first two members of inet_sock */
> so apparently there are other tricks that force specific layout in inet_sock
> which we dont have, or need.

  sk_alloc() asssumes that 'struct sock' is at the head 
'struct inet_sock' which needs to be at the head of the protocol 
specific structure.

-Libor



More information about the general mailing list