netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Lamparter <chunkeey@gmail.com>
To: Colin Ian King <colin.king@canonical.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Cc: Christian Lamparter <chunkeey@googlemail.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	"John W . Linville" <linville@tuxdriver.com>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] carl9170: Fix error return -EAGAIN if not started
Date: Fri, 8 Oct 2021 17:15:35 +0200	[thread overview]
Message-ID: <4e6efdf8-3c2e-68cd-5c23-b9809eceb331@gmail.com> (raw)
In-Reply-To: <382b719f-f14e-2963-284d-c0b38dedc4ae@canonical.com>

Hello,

On 08/10/2021 09:31, Colin Ian King wrote:
> On 08/10/2021 06:58, Dan Carpenter wrote:
>> On Fri, Oct 08, 2021 at 01:15:58AM +0100, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> There is an error return path where the error return is being
>>> assigned to err rather than count and the error exit path does
>>> not return -EAGAIN as expected. Fix this by setting the error
>>> return to variable count as this is the value that is returned
>>> at the end of the function.
>>>
>>> Addresses-Coverity: ("Unused value")
>>> Fixes: 00c4da27a421 ("carl9170: firmware parser and debugfs code")
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>> ---
>>>   drivers/net/wireless/ath/carl9170/debug.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/wireless/ath/carl9170/debug.c b/drivers/net/wireless/ath/carl9170/debug.c
>>> index bb40889d7c72..f163c6bdac8f 100644
>>> --- a/drivers/net/wireless/ath/carl9170/debug.c
>>> +++ b/drivers/net/wireless/ath/carl9170/debug.c
>>> @@ -628,7 +628,7 @@ static ssize_t carl9170_debugfs_bug_write(struct ar9170 *ar, const char *buf,
>>>       case 'R':
>>>           if (!IS_STARTED(ar)) {
>>> -            err = -EAGAIN;
>>> +            count = -EAGAIN;
>>>               goto out;
>>
>> This is ugly.  The bug wouldn't have happened with a direct return, it's
>> only the goto out which causes it.  Better to replace all the error
>> paths with direct returns.  There are two other direct returns so it's
>> not like a new thing...
> 
> Yep, I agree it was ugly, I was trying to keep to the coding style and reduce the patch delta size. I can do a V2 if the maintainers deem it's a cleaner solution.

Hm? I don't think there's any need to stick to a particular
coding style. This file hasn't been touched a lot since 2010.
Things moved on and replacing the gotos with straight return
is totally fine.

(It has to pass the build checkers of course. However I don't
think this will be a problem here...)

Cheers,
Christian

  parent reply	other threads:[~2021-10-08 15:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08  0:15 [PATCH] carl9170: Fix error return -EAGAIN if not started Colin King
2021-10-08  5:58 ` Dan Carpenter
2021-10-08  7:31   ` Colin Ian King
2021-10-08  7:43     ` Dan Carpenter
2021-10-08 15:15     ` Christian Lamparter [this message]
2021-10-10  8:05 ` Kalle Valo

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=4e6efdf8-3c2e-68cd-5c23-b9809eceb331@gmail.com \
    --to=chunkeey@gmail.com \
    --cc=chunkeey@googlemail.com \
    --cc=colin.king@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).