public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Antti Palosaari <crope@iki.fi>
To: "Michael Büsch" <m@bues.ch>, "Federico Simoncelli" <fsimonce@redhat.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Ondrej Zary <linux@rainbow-software.org>,
	Ramakrishnan Muthukrishnan <ramakrmu@cisco.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Takashi Iwai <tiwai@suse.de>,
	Amber Thrall <amber.rose.thrall@gmail.com>,
	James Harper <james.harper@ejbdigital.com.au>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH 2/2] drivers: Simplify the return code
Date: Tue, 19 May 2015 19:00:50 +0300	[thread overview]
Message-ID: <555B5E32.9060301@iki.fi> (raw)
In-Reply-To: <20150519141731.78744f2f@wiggum>

On 05/19/2015 03:17 PM, Michael Büsch wrote:
> On Tue, 19 May 2015 08:05:56 -0400 (EDT)
> Federico Simoncelli <fsimonce@redhat.com> wrote:
>>> diff --git a/drivers/media/dvb-frontends/lgs8gxx.c
>>> b/drivers/media/dvb-frontends/lgs8gxx.c
>>> index 3c92f36ea5c7..9b0166cdc7c2 100644
>>> --- a/drivers/media/dvb-frontends/lgs8gxx.c
>>> +++ b/drivers/media/dvb-frontends/lgs8gxx.c
>>> @@ -544,11 +544,7 @@ static int lgs8gxx_set_mpeg_mode(struct lgs8gxx_state
>>> *priv,
>>>   	t |= clk_pol ? TS_CLK_INVERTED : TS_CLK_NORMAL;
>>>   	t |= clk_gated ? TS_CLK_GATED : TS_CLK_FREERUN;
>>>
>>> -	ret = lgs8gxx_write_reg(priv, reg_addr, t);
>>> -	if (ret != 0)
>>> -		return ret;
>>> -
>>> -	return 0;
>>> +	return lgs8gxx_write_reg(priv, reg_addr, t);
>>>   }
>>
>> Personally I prefer the current style because it's more consistent with all
>> the other calls in the same function (return ret when ret != 0).
>>
>> It also allows you to easily add/remove calls without having to deal with
>> the last special case return my_last_fun_call(...).
>>
>> Anyway it's not a big deal, I think it's your call.
>
>
> I agree. I also prefer the current style for these reasons. The compiler will also generate the same code in both cases.
> I don't think it really simplifies the code.
> But if you really insist on doing this change, go for it. You get my ack for fc0011


I am also against that kind of simplifications. Even it reduces line or 
two, it makes code more inconsistent, which means you have to make extra 
thinking when reading that code. I prefer similar repeating patterns as 
much as possible.

This is how I do it usually, even there is that extra last goto.

	ret = write_reg();
	if (ret)
		goto err;

	ret = write_reg();
	if (ret)
		goto err;
err:
	return ret;
};

regards
Antti

-- 
http://palosaari.fi/

  reply	other threads:[~2015-05-19 16:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 11:00 [PATCH 1/2] usb drivers: use BUG_ON() instead of if () BUG Mauro Carvalho Chehab
2015-05-19 11:00 ` [PATCH 2/2] drivers: Simplify the return code Mauro Carvalho Chehab
2015-05-19 12:05   ` Federico Simoncelli
2015-05-19 12:17     ` Michael Büsch
2015-05-19 16:00       ` Antti Palosaari [this message]
2015-05-19 17:36         ` Dan Carpenter
2015-05-20  8:49         ` Mauro Carvalho Chehab
2015-05-20  8:39     ` Mauro Carvalho Chehab
2015-05-19 16:44 ` [PATCH 1/2] usb drivers: use BUG_ON() instead of if () BUG Lad, Prabhakar

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=555B5E32.9060301@iki.fi \
    --to=crope@iki.fi \
    --cc=amber.rose.thrall@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=fsimonce@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=james.harper@ejbdigital.com.au \
    --cc=konrad.wilk@oracle.com \
    --cc=lars@metafoo.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    --cc=m@bues.ch \
    --cc=mchehab@infradead.org \
    --cc=mchehab@osg.samsung.com \
    --cc=ramakrmu@cisco.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tiwai@suse.de \
    /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