staging: wfx: sta: Fix 'else' coding style warning
PATCH 1/1 staging: wfx: sta: Fix 'else' coding style warning
Fix 'else is not generally useful after a break or return' checkpatch warning
--- drivers/staging/wfx/sta.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/staging/wfx/sta.c +11 -12
@@ -169,19 +169,18 @@ static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps)if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps)dev_info (wvif->wdev->dev,"ignoring requested PS mode" );return -1 ; - }else { -/* It is necessary to enable PS if channels -* are different. -*/ -if (enable_ps) - *enable_ps = true; -if (wvif->wdev->force_ps_timeout >-1 ) -return wvif->wdev->force_ps_timeout; -else if (wfx_api_older_than (wvif->wdev,3 ,2 )) -return 0 ; -else -return 30 ; } +/* It is necessary to enable PS if channels +* are different. +*/ +if (enable_ps) + *enable_ps = true; +if (wvif->wdev->force_ps_timeout >-1 ) +return wvif->wdev->force_ps_timeout; +else if (wfx_api_older_than (wvif->wdev,3 ,2 )) +return 0 ; +else +return 30 ; }if (enable_ps) *enable_ps = wvif->vif->bss_conf.ps;
Signature · 1 line
2.25.1
Quoted 4 lines · Srivathsa Dara
Fix 'else is not generally useful after a break or return' checkpatch warning
Signed-off-by Srivathsa Dara <[email protected]>
It doesn't apply for me. Please check that you are working against staging-next or linux-next.
regards,
dan carpenter
Greg KH
maintainerQuoted 8 lines · Dan Carpenter
Quoted 4 lines · Srivathsa Dara
Fix 'else is not generally useful after a break or return' checkpatch warning
Signed-off-by Srivathsa Dara <[email protected]>It doesn't apply for me. Please check that you are working against staging-next or linux-next.
It applied for me, odd.
Hello Srivathsa,
Thank for your suggestion. However ...
Quoted 30 lines · On Tuesday 14 September 2021 16:31:06 CEST Srivathsa Dara wrote:
Fix 'else is not generally useful after a break or return' checkpatch warning
Signed-off-by Srivathsa Dara <[email protected]>--- drivers/staging/wfx/sta.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)drivers/staging/wfx/sta.c +1
-12@@ -169,19 +169,18 @@ static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps)if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps)dev_info (wvif->wdev->dev,"ignoring requested PS mode" );return -1 ; - }else { -/* It is necessary to enable PS if channels -* are different. -*/ -if (enable_ps) - *enable_ps = true; -if (wvif->wdev->force_ps_timeout >-1 ) -return wvif->wdev->force_ps_timeout; -else if (wfx_api_older_than (wvif->wdev,3 ,2 )) -return 0 ; -else -return 30 ; } +/* It is necessary to enable PS if channels
drivers/staging/wfx/sta.c static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) · line 183
Quoted 10 lines
drivers/staging/wfx/sta.c +10
-0+* are different. +*/ +if (enable_ps) + *enable_ps = true; +if (wvif->wdev->force_ps_timeout >-1 ) +return wvif->wdev->force_ps_timeout; +else if (wfx_api_older_than (wvif->wdev,3 ,2 )) +return 0 ; +else +return 30 ;
I am not a big fan of blindly applying the hints from checkpatch. With this patch, it seems that the code in the "if" branch is an exception and the rest of the code is the general case.
But, it is not true. There are two cases, and the author (me in fact) attended to express that that by using a "else" statement.
Signature · 1 line
Jérôme Pouiller
Greg KH
maintainerQuoted 50 lines · Jérôme Pouiller
Hello Srivathsa,
Thank for your suggestion. However ...
Quoted 30 lines · On Tuesday 14 September 2021 16:31:06 CEST Srivathsa Dara wrote:
Fix 'else is not generally useful after a break or return' checkpatch warning
Signed-off-by Srivathsa Dara <[email protected]>--- drivers/staging/wfx/sta.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)drivers/staging/wfx/sta.c +1
-12@@ -169,19 +169,18 @@ static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps)if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps)dev_info (wvif->wdev->dev,"ignoring requested PS mode" );return -1 ; - }else { -/* It is necessary to enable PS if channels -* are different. -*/ -if (enable_ps) - *enable_ps = true; -if (wvif->wdev->force_ps_timeout >-1 ) -return wvif->wdev->force_ps_timeout; -else if (wfx_api_older_than (wvif->wdev,3 ,2 )) -return 0 ; -else -return 30 ; } +/* It is necessary to enable PS if channels drivers/staging/wfx/sta.c static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) · line 183
Quoted 10 lines
drivers/staging/wfx/sta.c +10
-0+* are different. +*/ +if (enable_ps) + *enable_ps = true; +if (wvif->wdev->force_ps_timeout >-1 ) +return wvif->wdev->force_ps_timeout; +else if (wfx_api_older_than (wvif->wdev,3 ,2 )) +return 0 ; +else +return 30 ;I am not a big fan of blindly applying the hints from checkpatch. With this patch, it seems that the code in the "if" branch is an exception and the rest of the code is the general case.
Quoted 2 lines
But, it is not true. There are two cases, and the author (me in fact) attended to express that that by using a "else" statement.
But that first part of the if statement returns, making the second part not needed to be indented at all as the code flow just moves on here.
It's best not to indent if not needed, and it's not needed here as the tools are saying. So I've applied this.
thanks,
greg k-h