mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: fix unnecessary else block with only a break statement
@ 2026-09-09  8:29 Isaac Aneek Sarker
  2026-09-09  9:33 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Isaac Aneek Sarker @ 2026-09-09  8:29 UTC (permalink / raw)
  Cc: alvasarker2004, Greg Kroah-Hartman, Nikolay Kulikov,
	Andrei Khomenkov, Dalvin-Ehinoma Noah Aiguobas, Khushal Chitturi,
	Minu Jin, Anirban Bose, Khasar Munkh-Erdene, Jennifer Guo,
	linux-staging, linux-kernel

Warning found by checkpatch.pl : else is not generally useful after a
break or return. The function would reach the break statement after
if-elseif block even if the else block is not used.

Signed-off-by: Isaac Aneek Sarker <alvasarker2004@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 3c82012fdc6c..a203ef8bd6f6 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -1789,8 +1789,8 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un
 			/* Duplicate entry is found!! Do not insert current entry. */
 			/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
 			return false;
-		else
-			break;
+
+		break;
 	}
 
 	/* spin_lock_irqsave(&ppending_recvframe_queue->lock, irql); */
-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: rtl8723bs: fix unnecessary else block with only a break statement
  2026-09-09  8:29 [PATCH] staging: rtl8723bs: fix unnecessary else block with only a break statement Isaac Aneek Sarker
@ 2026-09-09  9:33 ` Greg Kroah-Hartman
  2026-09-09 13:37   ` Isaac Aneek Sarker
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-09-09  9:33 UTC (permalink / raw)
  To: Isaac Aneek Sarker
  Cc: Nikolay Kulikov, Andrei Khomenkov, Dalvin-Ehinoma Noah Aiguobas,
	Khushal Chitturi, Minu Jin, Anirban Bose, Khasar Munkh-Erdene,
	Jennifer Guo, linux-staging, linux-kernel

On Wed, Sep 09, 2026 at 02:29:38PM +0600, Isaac Aneek Sarker wrote:
> Warning found by checkpatch.pl : else is not generally useful after a
> break or return. The function would reach the break statement after
> if-elseif block even if the else block is not used.
> 
> Signed-off-by: Isaac Aneek Sarker <alvasarker2004@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_recv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> index 3c82012fdc6c..a203ef8bd6f6 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> @@ -1789,8 +1789,8 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un
>  			/* Duplicate entry is found!! Do not insert current entry. */
>  			/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
>  			return false;
> -		else
> -			break;
> +
> +		break;

Did you test this code?  It looks like you now just changed the logic a
lot, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: rtl8723bs: fix unnecessary else block with only a break statement
  2026-09-09  9:33 ` Greg Kroah-Hartman
@ 2026-09-09 13:37   ` Isaac Aneek Sarker
  2026-09-09 13:42     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Isaac Aneek Sarker @ 2026-09-09 13:37 UTC (permalink / raw)
  Cc: alvasarker2004, Greg Kroah-Hartman, Nikolay Kulikov,
	Andrei Khomenkov, Dalvin-Ehinoma Noah Aiguobas, Khushal Chitturi,
	Minu Jin, Anirban Bose, Khasar Munkh-Erdene, Jennifer Guo,
	linux-staging, linux-kernel

On Wed, 9 Sep 2026 11:33:49 +0200
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> On Wed, Sep 09, 2026 at 02:29:38PM +0600, Isaac Aneek Sarker wrote:
> > Warning found by checkpatch.pl : else is not generally useful after a
> > break or return. The function would reach the break statement after
> > if-elseif block even if the else block is not used.
> > 
> > Signed-off-by: Isaac Aneek Sarker <alvasarker2004@gmail.com>
> > ---
> >  drivers/staging/rtl8723bs/core/rtw_recv.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > index 3c82012fdc6c..a203ef8bd6f6 100644
> > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > @@ -1789,8 +1789,8 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un
> >  			/* Duplicate entry is found!! Do not insert current entry. */
> >  			/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
> >  			return false;
> > -		else
> > -			break;
> > +
> > +		break;
> 
> Did you test this code?  It looks like you now just changed the logic a
> lot, right?
> 
> thanks,
> 
> greg k-h

No I didn't test the code. And I don't have the required hardware. But I would like to know what are widely used test methods in linux kernel dev to test a driver when you don't have the relevant hardware vs when you have one for and finally test the code. At first it seemed a trivial change to me because that else block would only execute if the if-elseif block didnt execute, which made me come to the decision that the else block was unnecessary.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: rtl8723bs: fix unnecessary else block with only a break statement
  2026-09-09 13:37   ` Isaac Aneek Sarker
@ 2026-09-09 13:42     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-09-09 13:42 UTC (permalink / raw)
  To: Isaac Aneek Sarker
  Cc: Nikolay Kulikov, Andrei Khomenkov, Dalvin-Ehinoma Noah Aiguobas,
	Khushal Chitturi, Minu Jin, Anirban Bose, Khasar Munkh-Erdene,
	Jennifer Guo, linux-staging, linux-kernel

On Wed, Sep 09, 2026 at 07:37:36PM +0600, Isaac Aneek Sarker wrote:
> On Wed, 9 Sep 2026 11:33:49 +0200
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> 
> > On Wed, Sep 09, 2026 at 02:29:38PM +0600, Isaac Aneek Sarker wrote:
> > > Warning found by checkpatch.pl : else is not generally useful after a
> > > break or return. The function would reach the break statement after
> > > if-elseif block even if the else block is not used.
> > > 
> > > Signed-off-by: Isaac Aneek Sarker <alvasarker2004@gmail.com>
> > > ---
> > >  drivers/staging/rtl8723bs/core/rtw_recv.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > index 3c82012fdc6c..a203ef8bd6f6 100644
> > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > @@ -1789,8 +1789,8 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un
> > >  			/* Duplicate entry is found!! Do not insert current entry. */
> > >  			/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
> > >  			return false;
> > > -		else
> > > -			break;
> > > +
> > > +		break;
> > 
> > Did you test this code?  It looks like you now just changed the logic a
> > lot, right?
> > 
> > thanks,
> > 
> > greg k-h
> 
> No I didn't test the code. And I don't have the required hardware. But I would like to know what are widely used test methods in linux kernel dev to test a driver when you don't have the relevant hardware vs when you have one for and finally test the code. At first it seemed a trivial change to me because that else block would only execute if the if-elseif block didnt execute, which made me come to the decision that the else block was unnecessary.

Please wrap your lines :)

Look at the logic of what you just changed here, is it identical to what
was present before your change?  If not, what is different?  checkpatch
is for coding style issues, not logic changes, right?

See the mailing list archives for many discussions about this type of
"cleanup".

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-09 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09  8:29 [PATCH] staging: rtl8723bs: fix unnecessary else block with only a break statement Isaac Aneek Sarker
2026-09-09  9:33 ` Greg Kroah-Hartman
2026-09-09 13:37   ` Isaac Aneek Sarker
2026-09-09 13:42     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®