lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2258432.bcXerOTE6V@leap>
Date:   Wed, 20 Apr 2022 18:53:39 +0200
From:   "Fabio M. De Francesco" <fmdefrancesco@...il.com>
To:     Jaehee Park <jhpark1013@...il.com>, Kalle Valo <kvalo@...nel.org>
Cc:     Jérôme Pouiller <jerome.pouiller@...abs.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev,
        outreachy@...ts.linux.dev, Stefano Brivio <sbrivio@...hat.com>
Subject: Re: [PATCH] wfx: use container_of() to get vif

On mercoledì 20 aprile 2022 13:57:57 CEST Kalle Valo wrote:
> Jaehee Park <jhpark1013@...il.com> 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@...il.com>
> 
> [...]
> 
> > +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



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ