staging: r8188eu: replace rtw_netdev_priv define with inline function
PATCH 1/1 staging: r8188eu: replace rtw_netdev_priv define with inline function
The function guarantees type checking of arguments and return value.
--- drivers/staging/rtl8188eu/include/osdep_service.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/rtl8188eu/include/osdep_service.h +4 -2
@@ -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);#define FUNC_NDEV_FMT "%s(%s)"
Signature · 1 line
2.26.2
Greg Kroah-Hartman
maintainerQuoted 12 lines · Ivan Safonov
The function guarantees type checking of arguments and return value.
Signed-off-by Ivan Safonov <[email protected]>--- drivers/staging/rtl8188eu/include/osdep_service.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/staging/rtl8188eu/include/osdep_service.h +0
-0
drivers/staging/rtl8188eu/include/osdep_service.h struct rtw_netdev_priv_indicator { · line 78
Quoted 10 lines
drivers/staging/rtl8188eu/include/osdep_service.h +4
-2@@ -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?
And no blank line before the next function prototype?
And is this really needed? Type checking is already happening as this is a "simple" macro, right?
thanks,
greg k-h
Quoted 16 lines · Greg Kroah-Hartman
Quoted 15 lines · Ivan Safonov
The function guarantees type checking of arguments and return value.
Signed-off-by Ivan Safonov <[email protected]>--- drivers/staging/rtl8188eu/include/osdep_service.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/staging/rtl8188eu/include/osdep_service.h +0
-0@@ -71,8 +71,10 @@ struct rtw_netdev_priv_indicator { };struct net_device *rtw_alloc_etherdev_with_old_priv (void *old_priv);
Quoted 9 lines
drivers/staging/rtl8188eu/include/osdep_service.h struct rtw_netdev_priv_indicator { · line 78
Quoted 7 lines
drivers/staging/rtl8188eu/include/osdep_service.h +4
-2-#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.
Quoted 2 lines
And no blank line before the next function prototype?
In v2.
Quoted 3 lines
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.
Greg Kroah-Hartman
maintainerQuoted 26 lines · Ivan Safonov
Quoted 8 lines · Greg Kroah-Hartman
Quoted 7 lines · Ivan Safonov
The function guarantees type checking of arguments and return value.
Signed-off-by Ivan Safonov <[email protected]>--- drivers/staging/rtl8188eu/include/osdep_service.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)Quoted 16 lines
Quoted 5 lines
drivers/staging/rtl8188eu/include/osdep_service.h +0
-0drivers/staging/rtl8188eu/include/osdep_service.h struct rtw_netdev_priv_indicator { · line 77
Quoted 9 lines
drivers/staging/rtl8188eu/include/osdep_service.h +4
-2@@ -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?
Quoted 5 lines
(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.
Ah, sorry, missed that I thought this was a cast of netdev_priv(dev) itself, and not the additional structure.
Quoted 6 lines
Quoted 2 lines
And no blank line before the next function prototype?
In v2.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
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.
Ok, put that somewhere in the changelog please, saying how the existing macro does not provide any error checking.
thanks,
greg k-h