Skip to contentSkip to conversation

Staging: rtl8712: removed an unnecessary else statement

PATCH In review Karthik Nayak 3 participants 4 messages Dec 15, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8712: removed an unnecessary else statement

As per checkpatch warning, removed an unnecessary else statement proceeding an if statement with a return.

---
 drivers/staging/rtl8712/rtl8712_recv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8712/rtl8712_recv.c +1 -2
index cd8b444..800b2b3 100644
@@ -496,8 +496,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
 			plist = plist->next;
 		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);
Signature · 1 line
2.1.3
#1 lore raw
Quoted 2 lines · Karthik Nayak

As per checkpatch warning, removed an unnecessary else statement proceeding an if statement with a return.

This is not a correct change.
The checkpatch message said "generally".
You still have to verify the code.

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

Quoted 11 lines
drivers/staging/rtl8712/rtl8712_recv.c +1 -2
index cd8b444..800b2b3 100644
@@ -496,8 +496,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
 			plist = plist->next;
 		else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
 			return false;
-		else
-			break;
+		break;

It's not the same logic.
It would be if the code was:

	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)) {
			plist = plist->next;
			continue;
		} else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) {
			return false;
		}
		break;
	}

But that's not necessary.

#2 lore raw
Quoted 36 lines · Joe Perches
Quoted 2 lines · Karthik Nayak

As per checkpatch warning, removed an unnecessary else statement proceeding an if statement with a return.

This is not a correct change.
The checkpatch message said "generally".
You still have to verify the code.

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

Quoted 11 lines
drivers/staging/rtl8712/rtl8712_recv.c +1 -2
index cd8b444..800b2b3 100644
@@ -496,8 +496,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
  			plist = plist->next;
  		else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
  			return false;
-		else
-			break;
+		break;

It's not the same logic.
It would be if the code was:

	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)) {
			plist = plist->next;
			continue;
		} else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) {
			return false;
		}
		break;
	}
Quoted 1 line

But that's not necessary.

I have almost been tripped by this warning when the code said

	if (...) {
		.......
	} else if (...) {
		.......
		return;
	} else {
		.......
	}

Perhaps checkpatch should ignore setting this warning when there is an "else if" in the flow.

Larry

#3 lore raw
Quoted 8 lines · Larry Finger
Quoted 7 lines · Joe Perches
Quoted 2 lines · Karthik Nayak

As per checkpatch warning, removed an unnecessary else statement proceeding an if statement with a return.

This is not a correct change.
The checkpatch message said "generally".
You still have to verify the code.

[]

Quoted 2 lines

Perhaps checkpatch should ignore setting this warning when there is an "else if" in the flow.

In a patch, that's not possible as the
context may not show the flow.