Search Linux Wireless

Re: [PATCH] wfx: use container_of() to get vif

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On mercoledì 20 aprile 2022 13:57:57 CEST Kalle Valo wrote:
> Jaehee Park <jhpark1013@xxxxxxxxx> writes:
> 
> > Currently, upon virtual interface creation, wfx_add_interface() stores
> > a reference to the corresponding struct ieee80211_vif in private data,
> > for later usage. This is not needed when using the container_of
> > construct. This construct already has all the info it needs to retrieve
> > the reference to the corresponding struct from the offset that is
> > already available, inherent in container_of(), between its type and
> > member inputs (struct ieee80211_vif and drv_priv, respectively).
> > Remove vif (which was previously storing the reference to the struct
> > ieee80211_vif) from the struct wfx_vif, define a function
> > wvif_to_vif(wvif) for container_of(), and replace all wvif->vif with
> > the newly defined container_of construct.
> >
> > Signed-off-by: Jaehee Park <jhpark1013@xxxxxxxxx>
> 
> [...]
> 
> > +static inline struct ieee80211_vif *wvif_to_vif(struct wfx_vif *wvif)
> > +{
> > +	return container_of((void *)wvif, struct ieee80211_vif, 
drv_priv);
> > +}
> 
> Why the void pointer cast? Avoid casts as much possible.

In a previous email Jaehee wrote that she could compile her changes only by 
using that "(void *)" cast.

I replied that probably this is a hint that something is broken, although 
my argument is not necessarily a "proof". Might very well be that this cast 
was needed in this particular situation but I cannot see why.

@Jaehee, please try to explain why this "(void *)" cast is actually 
necessary and why your changes cannot avoid it.

Thanks,

Fabio M. De Francesco







[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux