All of lore.kernel.org
 help / color / mirror / Atom feed
From: Federico Simoncelli <fsimonce@redhat.com>
To: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>,
	Lars-Peter Clausen <lars@metafoo.de>, Michael Buesch <m@bues.ch>,
	Antti Palosaari <crope@iki.fi>, 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 08:05:56 -0400 (EDT)	[thread overview]
Message-ID: <577085828.1080862.1432037155994.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <a24b23db60ffee5cb32403d7c8cacd25b13f4510.1432033220.git.mchehab@osg.samsung.com>

----- Original Message -----
> From: "Mauro Carvalho Chehab" <mchehab@osg.samsung.com>
> To: "Linux Media Mailing List" <linux-media@vger.kernel.org>
> Cc: "Mauro Carvalho Chehab" <mchehab@osg.samsung.com>, "Mauro Carvalho Chehab" <mchehab@infradead.org>, "Lars-Peter
> Clausen" <lars@metafoo.de>, "Michael Buesch" <m@bues.ch>, "Antti Palosaari" <crope@iki.fi>, "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>, "Federico Simoncelli" <fsimonce@redhat.com>,
> "James Harper" <james.harper@ejbdigital.com.au>, "Dan Carpenter" <dan.carpenter@oracle.com>, "Konrad Rzeszutek Wilk"
> <konrad.wilk@oracle.com>
> Sent: Tuesday, May 19, 2015 1:00:57 PM
> Subject: [PATCH 2/2] drivers: Simplify the return code
> 
> If the last thing we do in a function is to call another
> function and then return its value, we don't need to store
> the returned code into some ancillary var.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> 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.
-- 
Federico

  reply	other threads:[~2015-05-19 12:08 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 [this message]
2015-05-19 12:17     ` Michael Büsch
2015-05-19 16:00       ` Antti Palosaari
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=577085828.1080862.1432037155994.JavaMail.zimbra@redhat.com \
    --to=fsimonce@redhat.com \
    --cc=amber.rose.thrall@gmail.com \
    --cc=crope@iki.fi \
    --cc=dan.carpenter@oracle.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 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.