Skip to contentSkip to conversation

rtl8712:Fix checkpatch warning

PATCH Superseded Ravi Teja Darbha 4 participants 4 messages Jun 29, 2015 – Jun 30, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtl8712:Fix checkpatch warning

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

---
 drivers/staging/rtl8712/rtl8712_recv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/rtl8712_recv.c +2 -2
index fcb8c61..4fa2540 100644
@@ -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 -
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 2 lines · Ravi Teja Darbha

1. Fix line over 80 characters warning.

Great, but:

Quoted 15 lines

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:

(quoted diff) +2 -0
+            return false;
+        else
while(condition1) {
    if(condition2)
        foo();
    else if(condition3)
        return false;
    else
        break;
}
Quoted 1 line

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:

Quoted 15 lines
drivers/staging/rtl8712/rtl8712_recv.c +2 -2
@@ -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 -
Signature · 1 line
1.9.1

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

greg k-h

#2 lore raw
In reply to Ravi Teja Darbha
Quoted 17 lines · Ravi Teja Darbha

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:

(quoted diff) +2 -0
+            return false;
+        else
while(condition1) {
    if(condition2)
        foo();
    else if(condition3)
        return false;
    else
        break;
}
Quoted 1 line

The else condition here cannot be eliminated

You can try something like this to eliminate the else:

drivers/staging/rtl8712/rtl8712_recv.c +4 -3
index fcb8c61..165161b 100644
@@ -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

#3 lore raw
Quoted 32 lines · Sudip Mukherjee
Quoted 17 lines · Ravi Teja Darbha

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:

(quoted diff) +2 -0
+            return false;
+        else
while(condition1) {
     if(condition2)
         foo();
     else if(condition3)
         return false;
     else
         break;
}
Quoted 1 line

The else condition here cannot be eliminated

You can try something like this to eliminate the else:

drivers/staging/rtl8712/rtl8712_recv.c +1 -1
index fcb8c61..165161b 100644
@@ -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;

drivers/staging/rtl8712/rtl8712_recv.c static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, · line 504

Quoted 10 lines
drivers/staging/rtl8712/rtl8712_recv.c +3 -2
+			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