All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Schmidt <stefan@osg.samsung.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-wpan@vger.kernel.org,
	Alexander Aring <alex.aring@gmail.com>,
	Alan Ott <alan@signal11.us>
Subject: Re: [PATCH bluetooth-next] ieee802154/mrf24j40: make sure we do not override return values
Date: Tue, 09 Jun 2015 10:52:17 +0200	[thread overview]
Message-ID: <5576A941.7030402@osg.samsung.com> (raw)
In-Reply-To: <DF4347EC-065D-4C46-947D-149085EDD466@holtmann.org>

Hello.

On 09/06/15 09:42, Marcel Holtmann wrote:
> Hi Stefan,
>
>> If we run into an error during rx we set the the error code in ret, but override
>> it afterwards. Using a different variable for the extra case avoids this
>> situation.
>>
>> CID: 1226982, 1226983
>> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
>> Cc: Alan Ott <alan@signal11.us>
>> ---
>> drivers/net/ieee802154/mrf24j40.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
>> index 99c7676..0b9b2ae 100644
>> --- a/drivers/net/ieee802154/mrf24j40.c
>> +++ b/drivers/net/ieee802154/mrf24j40.c
>> @@ -533,6 +533,7 @@ static int mrf24j40_handle_rx(struct mrf24j40 *devrec)
>> 	u8 lqi = 0;
>> 	u8 val;
>> 	int ret = 0;
>> +	int ret2 = 0;
>> 	struct sk_buff *skb;
>>
>> 	/* Turn off reception of packets off the air. This prevents the
>> @@ -569,9 +570,9 @@ static int mrf24j40_handle_rx(struct mrf24j40 *devrec)
>>
>> out:
>> 	/* Turn back on reception of packets off the air. */
>> -	ret = read_short_reg(devrec, REG_BBREG1, &val);
>> -	if (ret)
>> -		return ret;
>> +	ret2 = read_short_reg(devrec, REG_BBREG1, &val);
>> +	if (ret2)
>> +		return ret2;
> one of the general rule is to not declare a variable and assign it with a value unless really needed. In this case I think a simple int ret2; would be enough.

Fair enough. I just followed what was there already. Patch v2 send.

regards
Stefan Schmidt

  reply	other threads:[~2015-06-09  8:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-08 13:04 [PATCH bluetooth-next] ieee802154/mrf24j40: make sure we do not override return values Stefan Schmidt
2015-06-09  7:42 ` Marcel Holtmann
2015-06-09  8:52   ` Stefan Schmidt [this message]
2015-06-09 11:30     ` Alan Ott
2015-06-09 11:33       ` Alan Ott

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=5576A941.7030402@osg.samsung.com \
    --to=stefan@osg.samsung.com \
    --cc=alan@signal11.us \
    --cc=alex.aring@gmail.com \
    --cc=linux-wpan@vger.kernel.org \
    --cc=marcel@holtmann.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.