Re: [PATCH 2/2] drivers: Simplify the return code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



----- Original Message -----
> From: "Mauro Carvalho Chehab" <mchehab@xxxxxxxxxxxxxxx>
> To: "Linux Media Mailing List" <linux-media@xxxxxxxxxxxxxxx>
> Cc: "Mauro Carvalho Chehab" <mchehab@xxxxxxxxxxxxxxx>, "Mauro Carvalho Chehab" <mchehab@xxxxxxxxxxxxx>, "Lars-Peter
> Clausen" <lars@xxxxxxxxxx>, "Michael Buesch" <m@xxxxxxx>, "Antti Palosaari" <crope@xxxxxx>, "Hans Verkuil"
> <hverkuil@xxxxxxxxx>, "Sakari Ailus" <sakari.ailus@xxxxxxxxxxxxxxx>, "Ondrej Zary" <linux@xxxxxxxxxxxxxxxxxxxx>,
> "Ramakrishnan Muthukrishnan" <ramakrmu@xxxxxxxxx>, "Laurent Pinchart" <laurent.pinchart@xxxxxxxxxxxxxxxx>, "Takashi
> Iwai" <tiwai@xxxxxxx>, "Amber Thrall" <amber.rose.thrall@xxxxxxxxx>, "Federico Simoncelli" <fsimonce@xxxxxxxxxx>,
> "James Harper" <james.harper@xxxxxxxxxxxxxxxxx>, "Dan Carpenter" <dan.carpenter@xxxxxxxxxx>, "Konrad Rzeszutek Wilk"
> <konrad.wilk@xxxxxxxxxx>
> 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@xxxxxxxxxxxxxxx>
> 
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux