From: Javier Martinez Canillas <javier@osg.samsung.com>
To: Johan Hovold <johan@kernel.org>
Cc: linux-kernel@vger.kernel.org, Lee Jones <lee.jones@linaro.org>,
Samuel Ortiz <sameo@linux.intel.com>
Subject: Re: [PATCH 8/8] mfd: lm3533: Simplify function return logic
Date: Wed, 30 Sep 2015 23:41:26 +0200 [thread overview]
Message-ID: <560C5706.2030705@osg.samsung.com> (raw)
In-Reply-To: <20150930210437.GF4284@localhost>
Hello Johan,
On 09/30/2015 11:04 PM, Johan Hovold wrote:
> On Tue, Sep 29, 2015 at 01:26:08PM +0200, Javier Martinez Canillas wrote:
>> The invoked functions already return zero on success or a negative
>> errno code so there is no need to open code the logic in the caller.
>>
>> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
>
> I do not consider this an improvement in any way and suggest this patch
> is dropped.
>
Since I posted the patch I obviously disagree but I don't really mind
if the patch is dropped.
>> ---
>>
>> drivers/mfd/lm3533-core.c | 12 ++----------
>> 1 file changed, 2 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
>> index 643f3750e830..193ecee1fa7e 100644
>> --- a/drivers/mfd/lm3533-core.c
>> +++ b/drivers/mfd/lm3533-core.c
>> @@ -472,11 +472,7 @@ static int lm3533_device_setup(struct lm3533 *lm3533,
>> if (ret)
>> return ret;
>>
>> - ret = lm3533_set_boost_ovp(lm3533, pdata->boost_ovp);
>> - if (ret)
>> - return ret;
>> -
>> - return 0;
>> + return lm3533_set_boost_ovp(lm3533, pdata->boost_ovp);
>
> You're saving a few lines of code but instead introduce asymmetries and
> obscure the fact that the function returns zero on success.
>
I don't think the change makes the code more obscure tbh, the return foo()
construct is very common in the kernel and most functions return 0 on
success and a negative errno code on failure.
Also, we have a coccinelle semantic patch to find this pattern [0] so if
you think that is not worth it, please add a comment to the code. Otherwise
another developer could attempt to post the same patch since make coccicheck
will always complain about this file.
> Johan
>
[0]: http://lxr.free-electrons.com/source/scripts/coccinelle/misc/simple_return.cocci
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
next prev parent reply other threads:[~2015-09-30 21:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 11:26 [PATCH 0/8] mfd: Simplify return logic Javier Martinez Canillas
2015-09-29 11:26 ` [PATCH 1/8] mfd: htc-i2cpld: Remove unneded ret variable Javier Martinez Canillas
2015-10-01 7:17 ` Lee Jones
2015-09-29 11:26 ` [PATCH 2/8] mfd: arizona: " Javier Martinez Canillas
2015-09-29 11:24 ` Charles Keepax
2015-10-01 7:18 ` Lee Jones
2015-09-29 11:26 ` [PATCH 3/8] mfd: pcf50633: " Javier Martinez Canillas
2015-10-01 7:18 ` Lee Jones
2015-09-29 11:26 ` [PATCH 4/8] mfd: kempld-core: Simplify function return logic Javier Martinez Canillas
2015-10-01 7:19 ` Lee Jones
2015-09-29 11:26 ` [PATCH 5/8] mfd: rtsx: " Javier Martinez Canillas
2015-10-01 7:19 ` Lee Jones
2015-09-29 11:26 ` [PATCH 6/8] mfd: da903x: " Javier Martinez Canillas
2015-09-29 12:24 ` Opensource [Adam Thomson]
2015-10-01 7:20 ` Lee Jones
2015-09-29 11:26 ` [PATCH 7/8] mfd: da9052: " Javier Martinez Canillas
2015-09-29 12:24 ` Opensource [Adam Thomson]
2015-10-01 7:20 ` Lee Jones
2015-09-29 11:26 ` [PATCH 8/8] mfd: lm3533: " Javier Martinez Canillas
2015-09-30 21:04 ` Johan Hovold
2015-09-30 21:41 ` Javier Martinez Canillas [this message]
2015-09-30 21:55 ` Johan Hovold
2015-10-01 7:17 ` Lee Jones
2015-10-01 17:59 ` Johan Hovold
2015-10-01 7:21 ` Lee Jones
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=560C5706.2030705@osg.samsung.com \
--to=javier@osg.samsung.com \
--cc=johan@kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.com \
/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).