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: <968d30fc-4e5f-b495-e986-b18b05e9a895@gmail.com>
Date:   Sat, 1 Aug 2020 16:11:38 +0300
From:   Ivan Safonov <insafonov@...il.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Larry Finger <Larry.Finger@...inger.net>,
        devel@...verdev.osuosl.org, B K Karthik <bkkarthik@...u.pes.edu>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: r8188eu: replace rtw_netdev_priv define with
 inline function

On 8/1/20 12:51 PM, Greg Kroah-Hartman wrote:
> On Sat, Aug 01, 2020 at 12:47:07PM +0300, Ivan Safonov wrote:
>> The function guarantees type checking of arguments and return value.
>>
>> Signed-off-by: Ivan Safonov <insafonov@...il.com>
>> ---
>>   drivers/staging/rtl8188eu/include/osdep_service.h | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
>> index 31d897f1d21f..e0ccafdea9cd 100644
>> --- a/drivers/staging/rtl8188eu/include/osdep_service.h
>> +++ b/drivers/staging/rtl8188eu/include/osdep_service.h
>> @@ -71,8 +71,10 @@ struct rtw_netdev_priv_indicator {
>>   };
>>   struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv);
>>   
>> -#define rtw_netdev_priv(netdev)					\
>> -	(((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv)
>> +static inline struct adapter *rtw_netdev_priv(struct net_device *dev)
>> +{
>> +	return (((struct rtw_netdev_priv_indicator *)netdev_priv(dev))->priv);
>> +}
>>   void rtw_free_netdev(struct net_device *netdev);
> 
> Is the cast really needed?

(struct rtw_netdev_priv_indicator *) cast needed for access to '->priv'.

The (struct adapter *) return type is a starting point for simplify
     struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
constructions.

> 
> And no blank line before the next function prototype?

In v2.

> 
> And is this really needed?  Type checking is already happening as this
> is a "simple" macro, right?

1. The flexibility of macros is not needed here.
2. The macro silently assigns ->priv to any pointer, while the function 
indicates such a compile-time error.

Ivan Safonov.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ