staging: wlan-ng: collect return status without variable
PATCH 1/1 staging: wlan-ng: collect return status without variable
err and result variables are declared to collect return status of prism2_domibset_uint32.
Check return status in if loop and return directly.
Rearragne code such that we can avoid declaring these variables.
--- drivers/staging/wlan-ng/cfg80211.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/staging/wlan-ng/cfg80211.c +6 -11
@@ -231,17 +231,12 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, {struct wlandevice *wlandev = dev->ml_priv; -int err =0 ; -int result =0 ; - - result =prism2_domibset_uint32 (wlandev, -DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , - key_index); - -if (result) - err = -EFAULT ; - -return err; +if (prism2_domibset_uint32 (wlandev, +DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , + key_index)) +return -EFAULT ; +else +return 0 ; } static int prism2_get_station(struct wiphy *wiphy, struct net_device *dev,
Signature · 1 line
2.7.4
Quoted 15 lines · Hariprasad Kelam
drivers/staging/wlan-ng/cfg80211.c +0
-7@@ -231,17 +231,12 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, {struct wlandevice *wlandev = dev->ml_priv; -int err =0 ; -int result =0 ; - - result =prism2_domibset_uint32 (wlandev, -DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , - key_index); -
drivers/staging/wlan-ng/cfg80211.c static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, · line 239
Quoted 10 lines
drivers/staging/wlan-ng/cfg80211.c +6
-4-if (result) - err = -EFAULT ; - -return err; +if (prism2_domibset_uint32 (wlandev, +DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , + key_index)) +return -EFAULT ; +else +return 0 ;
We should just preserve the error codes from prism2_domibset_uint32().
return prism2_domibset_uint32(dev->ml_priv, DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, key_index);
regards,
dan carpenter
Quoted 29 lines · Dan Carpenter
Quoted 15 lines · Hariprasad Kelam
drivers/staging/wlan-ng/cfg80211.c +0
-7@@ -231,17 +231,12 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, {struct wlandevice *wlandev = dev->ml_priv; -int err =0 ; -int result =0 ; - - result =prism2_domibset_uint32 (wlandev, -DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , - key_index); -drivers/staging/wlan-ng/cfg80211.c static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, · line 239
Quoted 10 lines
drivers/staging/wlan-ng/cfg80211.c +6
-4-if (result) - err = -EFAULT ; - -return err; +if (prism2_domibset_uint32 (wlandev, +DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , + key_index)) +return -EFAULT ; +else +return 0 ;We should just preserve the error codes from
prism2_domibset_uint32().
Quoted 4 lines
return prism2_domibset_uint32(dev->ml_priv, DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, key_index);
prism2_domibset_uint32 function can return -ENODEV,-EPERM,-EBUSY if fail case.
If we observe the pattern of calling this function,we can find
"return -EFAULT on failure and 0 on success".
Due to this we can not collect return status directly.
Quoted 3 lines
regards,
dan carpenter
Quoted 34 lines · Hariprasad Kelam
Quoted 29 lines · Dan Carpenter
Quoted 15 lines · Hariprasad Kelam
drivers/staging/wlan-ng/cfg80211.c +0
-7@@ -231,17 +231,12 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, {struct wlandevice *wlandev = dev->ml_priv; -int err =0 ; -int result =0 ; - - result =prism2_domibset_uint32 (wlandev, -DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , - key_index); -drivers/staging/wlan-ng/cfg80211.c static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, · line 239
Quoted 10 lines
drivers/staging/wlan-ng/cfg80211.c +6
-4-if (result) - err = -EFAULT ; - -return err; +if (prism2_domibset_uint32 (wlandev, +DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , + key_index)) +return -EFAULT ; +else +return 0 ;We should just preserve the error codes from
prism2_domibset_uint32().Quoted 4 lines
return prism2_domibset_uint32(dev->ml_priv, DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, key_index);
Quoted 8 lines
prism2_domibset_uint32function can return -ENODEV,-EPERM,-EBUSY if fail case.If we observe the pattern of calling this function,we can find
"return
-EFAULTon failure and 0 on success".Due to this we can not collect return status directly.
Yes, I know this code is full of nonsense.
It shouldn't just always return -EFAULT, it should preserve the correct error code. This is only called from rdev_set_default_key() if you want to check the caller.
regards,
dan carpenter
Quoted 44 lines · Dan Carpenter
Quoted 34 lines · Hariprasad Kelam
Quoted 29 lines · Dan Carpenter
Quoted 15 lines · Hariprasad Kelam
drivers/staging/wlan-ng/cfg80211.c +0
-7@@ -231,17 +231,12 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, {struct wlandevice *wlandev = dev->ml_priv; -int err =0 ; -int result =0 ; - - result =prism2_domibset_uint32 (wlandev, -DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , - key_index); -drivers/staging/wlan-ng/cfg80211.c static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, · line 239
Quoted 10 lines
drivers/staging/wlan-ng/cfg80211.c +6
-4-if (result) - err = -EFAULT ; - -return err; +if (prism2_domibset_uint32 (wlandev, +DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID , + key_index)) +return -EFAULT ; +else +return 0 ;We should just preserve the error codes from
prism2_domibset_uint32().Quoted 4 lines
return prism2_domibset_uint32(dev->ml_priv, DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, key_index);Quoted 8 lines
prism2_domibset_uint32function can return -ENODEV,-EPERM,-EBUSY if fail case.If we observe the pattern of calling this function,we can find
"return
-EFAULTon failure and 0 on success".Due to this we can not collect return status directly.
Quoted 8 lines
Yes, I know this code is full of nonsense.
It shouldn't just always return
-EFAULT, it should preserve the correct error code. This is only called fromrdev_set_default_key()if you want to check the caller.regards,
dan carpenter
Yes , Caller not particular about -EFAULT,there is no need of masking all errors with EFAULT in fail case.
We can directly collect the return status.
Will resend the patch with suggested changes
Thanks,
Hariprasad k