linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtl8712:Fix checkpatch warning
@ 2015-06-29 19:57 Ravi Teja Darbha
  2015-06-29 20:09 ` Greg KH
  2015-06-30  4:29 ` Sudip Mukherjee
  0 siblings, 2 replies; 4+ messages in thread
From: Ravi Teja Darbha @ 2015-06-29 19:57 UTC (permalink / raw)
  To: Larry.Finger, florian.c.schilhabel
  Cc: gregkh, mahfouz.saif.elyazal, vthakkar1994, haggai.eran,
	sudipm.mukherjee, krinkin.m.u, krinkin.m.u, devel, linux-kernel


1. Fix line over 80 characters warning.
2. The checkpatch warning at line 499 seems to be false positive.
WARNING: else is not generally useful after a break or return
#499: FILE: rtl8712_recv.c:499:
+            return false;
+        else

while(condition1) {
    if(condition2)
        foo();
    else if(condition3)
        return false;
    else
        break;
}

The else condition here cannot be eliminated

Signed-off-by: Ravi Teja Darbha <ravi2j@gmail.com>
---
 drivers/staging/rtl8712/rtl8712_recv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index fcb8c61..4fa2540 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -58,8 +58,8 @@ int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter)
 
     /*init recv_buf*/
     _init_queue(&precvpriv->free_recv_buf_queue);
-    precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4,
-                         GFP_ATOMIC);
+    precvpriv->pallocated_recv_buf =
+        kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, GFP_ATOMIC);
     if (precvpriv->pallocated_recv_buf == NULL)
         return _FAIL;
     precvpriv->precv_buf = precvpriv->pallocated_recv_buf + 4 -
-- 
1.9.1


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

* Re: [PATCH] rtl8712:Fix checkpatch warning
  2015-06-29 19:57 [PATCH] rtl8712:Fix checkpatch warning Ravi Teja Darbha
@ 2015-06-29 20:09 ` Greg KH
  2015-06-30  4:29 ` Sudip Mukherjee
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2015-06-29 20:09 UTC (permalink / raw)
  To: Ravi Teja Darbha
  Cc: Larry.Finger, florian.c.schilhabel, mahfouz.saif.elyazal,
	vthakkar1994, haggai.eran, sudipm.mukherjee, krinkin.m.u, devel,
	linux-kernel

On Tue, Jun 30, 2015 at 01:27:47AM +0530, Ravi Teja Darbha wrote:
> 
> 1. Fix line over 80 characters warning.

Great, but:

> 2. The checkpatch warning at line 499 seems to be false positive.
> WARNING: else is not generally useful after a break or return
> #499: FILE: rtl8712_recv.c:499:
> +            return false;
> +        else
> 
> while(condition1) {
>     if(condition2)
>         foo();
>     else if(condition3)
>         return false;
>     else
>         break;
> }
> 
> The else condition here cannot be eliminated

Why does that belong here in this changelog entry?  Why would you want
this text to show up in the kernel log?

Please fix up.

Also:

> --- a/drivers/staging/rtl8712/rtl8712_recv.c
> +++ b/drivers/staging/rtl8712/rtl8712_recv.c
> @@ -58,8 +58,8 @@ int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter)
>  
>      /*init recv_buf*/
>      _init_queue(&precvpriv->free_recv_buf_queue);
> -    precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4,
> -                         GFP_ATOMIC);
> +    precvpriv->pallocated_recv_buf =
> +        kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, GFP_ATOMIC);
>      if (precvpriv->pallocated_recv_buf == NULL)
>          return _FAIL;
>      precvpriv->precv_buf = precvpriv->pallocated_recv_buf + 4 -
> -- 
> 1.9.1

Your patches are corrupted and can not be applied.  Please fix your
email client.

greg k-h

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

* Re: [PATCH] rtl8712:Fix checkpatch warning
  2015-06-29 19:57 [PATCH] rtl8712:Fix checkpatch warning Ravi Teja Darbha
  2015-06-29 20:09 ` Greg KH
@ 2015-06-30  4:29 ` Sudip Mukherjee
  2015-06-30  5:56   ` Larry Finger
  1 sibling, 1 reply; 4+ messages in thread
From: Sudip Mukherjee @ 2015-06-30  4:29 UTC (permalink / raw)
  To: Ravi Teja Darbha
  Cc: Larry.Finger, florian.c.schilhabel, gregkh, mahfouz.saif.elyazal,
	vthakkar1994, haggai.eran, krinkin.m.u, devel, linux-kernel

On Tue, Jun 30, 2015 at 01:27:47AM +0530, Ravi Teja Darbha wrote:
> 
> 1. Fix line over 80 characters warning.
> 2. The checkpatch warning at line 499 seems to be false positive.
> WARNING: else is not generally useful after a break or return
> #499: FILE: rtl8712_recv.c:499:
> +            return false;
> +        else
> 
> while(condition1) {
>     if(condition2)
>         foo();
>     else if(condition3)
>         return false;
>     else
>         break;
> }
> 
> The else condition here cannot be eliminated
You can try something like this to eliminate the else:

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index fcb8c61..165161b 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -492,12 +492,13 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
 	while (end_of_queue_search(phead, plist) == false) {
 		pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
 		pnextattrib = &pnextrframe->u.hdr.attrib;
-		if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
+		if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) {
 			plist = plist->next;
+			continue;
+		}
 		else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
 			return false;
-		else
-			break;
+		break;
 	}
 	list_del_init(&(prframe->u.hdr.list));
 	list_add_tail(&(prframe->u.hdr.list), plist);

regards
sudip

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

* Re: [PATCH] rtl8712:Fix checkpatch warning
  2015-06-30  4:29 ` Sudip Mukherjee
@ 2015-06-30  5:56   ` Larry Finger
  0 siblings, 0 replies; 4+ messages in thread
From: Larry Finger @ 2015-06-30  5:56 UTC (permalink / raw)
  To: Sudip Mukherjee, Ravi Teja Darbha
  Cc: florian.c.schilhabel, gregkh, mahfouz.saif.elyazal, vthakkar1994,
	haggai.eran, krinkin.m.u, devel, linux-kernel

On 06/29/2015 11:29 PM, Sudip Mukherjee wrote:
> On Tue, Jun 30, 2015 at 01:27:47AM +0530, Ravi Teja Darbha wrote:
>>
>> 1. Fix line over 80 characters warning.
>> 2. The checkpatch warning at line 499 seems to be false positive.
>> WARNING: else is not generally useful after a break or return
>> #499: FILE: rtl8712_recv.c:499:
>> +            return false;
>> +        else
>>
>> while(condition1) {
>>      if(condition2)
>>          foo();
>>      else if(condition3)
>>          return false;
>>      else
>>          break;
>> }
>>
>> The else condition here cannot be eliminated
> You can try something like this to eliminate the else:
>
> diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
> index fcb8c61..165161b 100644
> --- a/drivers/staging/rtl8712/rtl8712_recv.c
> +++ b/drivers/staging/rtl8712/rtl8712_recv.c
> @@ -492,12 +492,13 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
>   	while (end_of_queue_search(phead, plist) == false) {
>   		pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
>   		pnextattrib = &pnextrframe->u.hdr.attrib;
> -		if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
> +		if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) {
>   			plist = plist->next;
> +			continue;
> +		}
>   		else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
>   			return false;
> -		else
> -			break;
> +		break;
>   	}
>   	list_del_init(&(prframe->u.hdr.list));
>   	list_add_tail(&(prframe->u.hdr.list), plist);

NACK on this idea. Checkpatch is not the complete arbiter of style. Just leave 
the code alone.

Larry



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

end of thread, other threads:[~2015-06-30  5:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-29 19:57 [PATCH] rtl8712:Fix checkpatch warning Ravi Teja Darbha
2015-06-29 20:09 ` Greg KH
2015-06-30  4:29 ` Sudip Mukherjee
2015-06-30  5:56   ` Larry Finger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).