* [PATCH] Staging: rtl8712: removed an unnecessary else statement
@ 2014-12-15 15:25 Karthik Nayak
2014-12-15 16:39 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Karthik Nayak @ 2014-12-15 15:25 UTC (permalink / raw)
To: trivial; +Cc: linux-kernel, gregkh, Larry.Finger, Karthik Nayak
As per checkpatch warning, removed an unnecessary else statement
proceeding an if statement with a return.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
drivers/staging/rtl8712/rtl8712_recv.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index cd8b444..800b2b3 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -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);
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Staging: rtl8712: removed an unnecessary else statement
2014-12-15 15:25 [PATCH] Staging: rtl8712: removed an unnecessary else statement Karthik Nayak
@ 2014-12-15 16:39 ` Joe Perches
2014-12-15 17:12 ` Larry Finger
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-12-15 16:39 UTC (permalink / raw)
To: Karthik Nayak; +Cc: trivial, linux-kernel, gregkh, Larry.Finger
On Mon, 2014-12-15 at 20:55 +0530, Karthik Nayak wrote:
> 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.
> diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
> index cd8b444..800b2b3 100644
> --- a/drivers/staging/rtl8712/rtl8712_recv.c
> +++ b/drivers/staging/rtl8712/rtl8712_recv.c
> @@ -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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Staging: rtl8712: removed an unnecessary else statement
2014-12-15 16:39 ` Joe Perches
@ 2014-12-15 17:12 ` Larry Finger
2014-12-15 17:27 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Larry Finger @ 2014-12-15 17:12 UTC (permalink / raw)
To: Joe Perches, Karthik Nayak; +Cc: trivial, linux-kernel, gregkh
On 12/15/2014 10:39 AM, Joe Perches wrote:
> On Mon, 2014-12-15 at 20:55 +0530, Karthik Nayak wrote:
>> 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.
>
>> diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
>> index cd8b444..800b2b3 100644
>> --- a/drivers/staging/rtl8712/rtl8712_recv.c
>> +++ b/drivers/staging/rtl8712/rtl8712_recv.c
>> @@ -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.
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Staging: rtl8712: removed an unnecessary else statement
2014-12-15 17:12 ` Larry Finger
@ 2014-12-15 17:27 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2014-12-15 17:27 UTC (permalink / raw)
To: Larry Finger; +Cc: Karthik Nayak, trivial, linux-kernel, gregkh
On Mon, 2014-12-15 at 11:12 -0600, Larry Finger wrote:
> On 12/15/2014 10:39 AM, Joe Perches wrote:
> > On Mon, 2014-12-15 at 20:55 +0530, Karthik Nayak wrote:
> >> 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.
[]
> 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-15 17:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-15 15:25 [PATCH] Staging: rtl8712: removed an unnecessary else statement Karthik Nayak
2014-12-15 16:39 ` Joe Perches
2014-12-15 17:12 ` Larry Finger
2014-12-15 17:27 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox