[PATCH] staging: rtl8723bs: reorder conditions to avoid else branch

myeonghyeon.park posted 1 patch 1 month, 1 week ago
drivers/staging/rtl8723bs/core/rtw_recv.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
[PATCH] staging: rtl8723bs: reorder conditions to avoid else branch
Posted by myeonghyeon.park 1 month, 1 week ago
Fix the checkpatch.pl warning:

"WARNING: else is not generally useful after a break or return"

in core/rtw_recv.c.

Return early when the SN_EQUAL() condition is met and break when
SN_LESS() condition is false to eliminate the unnecessary else branch.

Signed-off-by: myeonghyeon.park <myeonghyeon.park@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 7568fc514d7c..5776d0212ab8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -1782,14 +1782,15 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un
 		pnextrframe = (union recv_frame *)plist;
 		pnextattrib = &pnextrframe->u.hdr.attrib;
 
-		if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
-			plist = get_next(plist);
-		else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
+		if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
 			/* Duplicate entry is found!! Do not insert current entry. */
 			/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
 			return false;
-		else
+
+		if (!SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
 			break;
+
+		plist = get_next(plist);
 	}
 
 	/* spin_lock_irqsave(&ppending_recvframe_queue->lock, irql); */
-- 
2.52.0
Re: [PATCH] staging: rtl8723bs: reorder conditions to avoid else branch
Posted by Dan Carpenter 1 month, 1 week ago
On Fri, Aug 21, 2026 at 01:26:01AM +0900, myeonghyeon.park wrote:
> Fix the checkpatch.pl warning:
> 
> "WARNING: else is not generally useful after a break or return"
> 
> in core/rtw_recv.c.
> 
> Return early when the SN_EQUAL() condition is met and break when
> SN_LESS() condition is false to eliminate the unnecessary else branch.
> 

Just ignore checkpatch when it is wrong.

regards,
dan carpenter
Re: [PATCH] staging: rtl8723bs: reorder conditions to avoid else branch
Posted by Greg Kroah-Hartman 1 month, 1 week ago
On Fri, Aug 21, 2026 at 01:26:01AM +0900, myeonghyeon.park wrote:
> Fix the checkpatch.pl warning:
> 
> "WARNING: else is not generally useful after a break or return"
> 
> in core/rtw_recv.c.
> 
> Return early when the SN_EQUAL() condition is met and break when
> SN_LESS() condition is false to eliminate the unnecessary else branch.
> 
> Signed-off-by: myeonghyeon.park <myeonghyeon.park@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_recv.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

> diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> index 7568fc514d7c..5776d0212ab8 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> @@ -1782,14 +1782,15 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un
>  		pnextrframe = (union recv_frame *)plist;
>  		pnextattrib = &pnextrframe->u.hdr.attrib;
>  
> -		if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
> -			plist = get_next(plist);
> -		else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
> +		if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
>  			/* Duplicate entry is found!! Do not insert current entry. */
>  			/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
>  			return false;
> -		else
> +
> +		if (!SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
>  			break;
> +
> +		plist = get_next(plist);
>  	}
>  
>  	/* spin_lock_irqsave(&ppending_recvframe_queue->lock, irql); */
> -- 
> 2.52.0
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- It looks like you did not use your "real" name for the patch on either
  the Signed-off-by: line, or the From: line (both of which have to
  match).  Please read the kernel file,
  Documentation/process/submitting-patches.rst for how to do this
  correctly.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot