All of lore.kernel.org
 help / color / mirror / Atom feed
From: Larry Finger <Larry.Finger@lwfinger.net>
To: Joe Perches <joe@perches.com>, Karthik Nayak <karthik.188@gmail.com>
Cc: trivial@kernel.org, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org
Subject: Re: [PATCH] Staging: rtl8712: removed an unnecessary else statement
Date: Mon, 15 Dec 2014 11:12:38 -0600	[thread overview]
Message-ID: <548F1686.4080507@lwfinger.net> (raw)
In-Reply-To: <1418661543.2674.17.camel@perches.com>

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


  reply	other threads:[~2014-12-15 17:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2014-12-15 17:27     ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=548F1686.4080507@lwfinger.net \
    --to=larry.finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=karthik.188@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.