* [PATCH] staging: wlan-ng: collect return status without variable @ 2019-05-10 2:39 Hariprasad Kelam 2019-05-10 10:57 ` Dan Carpenter 0 siblings, 1 reply; 5+ messages in thread From: Hariprasad Kelam @ 2019-05-10 2:39 UTC (permalink / raw) To: Greg Kroah-Hartman, Tim Collier, Chris Opperman, Hariprasad Kelam, devel, linux-kernel 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. Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com> --- drivers/staging/wlan-ng/cfg80211.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 8a862f7..5dad5ac 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -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, -- 2.7.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wlan-ng: collect return status without variable 2019-05-10 2:39 [PATCH] staging: wlan-ng: collect return status without variable Hariprasad Kelam @ 2019-05-10 10:57 ` Dan Carpenter 2019-05-10 17:23 ` Hariprasad Kelam 0 siblings, 1 reply; 5+ messages in thread From: Dan Carpenter @ 2019-05-10 10:57 UTC (permalink / raw) To: Hariprasad Kelam Cc: Greg Kroah-Hartman, Tim Collier, Chris Opperman, devel, linux-kernel On Fri, May 10, 2019 at 08:09:00AM +0530, Hariprasad Kelam wrote: > diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c > index 8a862f7..5dad5ac 100644 > --- a/drivers/staging/wlan-ng/cfg80211.c > +++ b/drivers/staging/wlan-ng/cfg80211.c > @@ -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; 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wlan-ng: collect return status without variable 2019-05-10 10:57 ` Dan Carpenter @ 2019-05-10 17:23 ` Hariprasad Kelam 2019-05-10 18:40 ` Dan Carpenter 0 siblings, 1 reply; 5+ messages in thread From: Hariprasad Kelam @ 2019-05-10 17:23 UTC (permalink / raw) To: Dan Carpenter, Greg Kroah-Hartman, Tim Collier, Chris Opperman, devel, linux-kernel On Fri, May 10, 2019 at 01:57:54PM +0300, Dan Carpenter wrote: > On Fri, May 10, 2019 at 08:09:00AM +0530, Hariprasad Kelam wrote: > > diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c > > index 8a862f7..5dad5ac 100644 > > --- a/drivers/staging/wlan-ng/cfg80211.c > > +++ b/drivers/staging/wlan-ng/cfg80211.c > > @@ -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; > > We should just preserve the error codes from prism2_domibset_uint32(). > > 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. > regards, > dan carpenter > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wlan-ng: collect return status without variable 2019-05-10 17:23 ` Hariprasad Kelam @ 2019-05-10 18:40 ` Dan Carpenter 2019-05-11 7:58 ` Hariprasad Kelam 0 siblings, 1 reply; 5+ messages in thread From: Dan Carpenter @ 2019-05-10 18:40 UTC (permalink / raw) To: Hariprasad Kelam Cc: Greg Kroah-Hartman, Tim Collier, Chris Opperman, devel, linux-kernel On Fri, May 10, 2019 at 10:53:08PM +0530, Hariprasad Kelam wrote: > On Fri, May 10, 2019 at 01:57:54PM +0300, Dan Carpenter wrote: > > On Fri, May 10, 2019 at 08:09:00AM +0530, Hariprasad Kelam wrote: > > > diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c > > > index 8a862f7..5dad5ac 100644 > > > --- a/drivers/staging/wlan-ng/cfg80211.c > > > +++ b/drivers/staging/wlan-ng/cfg80211.c > > > @@ -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; > > > > We should just preserve the error codes from prism2_domibset_uint32(). > > > > 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. 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wlan-ng: collect return status without variable 2019-05-10 18:40 ` Dan Carpenter @ 2019-05-11 7:58 ` Hariprasad Kelam 0 siblings, 0 replies; 5+ messages in thread From: Hariprasad Kelam @ 2019-05-11 7:58 UTC (permalink / raw) To: Dan Carpenter, Greg Kroah-Hartman, Tim Collier, Chris Opperman, Hariprasad Kelam, devel, linux-kernel On Fri, May 10, 2019 at 09:40:11PM +0300, Dan Carpenter wrote: > On Fri, May 10, 2019 at 10:53:08PM +0530, Hariprasad Kelam wrote: > > On Fri, May 10, 2019 at 01:57:54PM +0300, Dan Carpenter wrote: > > > On Fri, May 10, 2019 at 08:09:00AM +0530, Hariprasad Kelam wrote: > > > > diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c > > > > index 8a862f7..5dad5ac 100644 > > > > --- a/drivers/staging/wlan-ng/cfg80211.c > > > > +++ b/drivers/staging/wlan-ng/cfg80211.c > > > > @@ -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; > > > > > > We should just preserve the error codes from prism2_domibset_uint32(). > > > > > > 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. > > 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 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-05-11 8:04 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-05-10 2:39 [PATCH] staging: wlan-ng: collect return status without variable Hariprasad Kelam 2019-05-10 10:57 ` Dan Carpenter 2019-05-10 17:23 ` Hariprasad Kelam 2019-05-10 18:40 ` Dan Carpenter 2019-05-11 7:58 ` Hariprasad Kelam
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox