lkml.org 
[lkml]   [2015]   [Oct]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 07/18] Input: cap11xx - simplify function return logic
On Fri, Oct 02, 2015 at 03:40:18PM +0200, Javier Martinez Canillas wrote:
> The invoked function already returns zero on success or a negative
> errno code so there is no need to open code the logic in the caller.
>
> This also fixes the following make coccicheck warning:
>
> drivers/input/keyboard/cap11xx.c:475:1-6: WARNING: end returns can be simplified
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> ---
>
> drivers/input/keyboard/cap11xx.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c
> index 378db10001df..7240316ddfe3 100644
> --- a/drivers/input/keyboard/cap11xx.c
> +++ b/drivers/input/keyboard/cap11xx.c
> @@ -472,12 +472,8 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
> return -ENXIO;
> }
>
> - error = devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
> - IRQF_ONESHOT, dev_name(dev), priv);
> - if (error)
> - return error;
> -
> - return 0;
> + return devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
> + IRQF_ONESHOT, dev_name(dev), priv);
> }

For cases where we have multiple of potentially failing actions:

error = action1();
if (error)
return error;

error = action2();
if (error)
return error;

error = action3();
if (error)
return error;

return 0;

I prefer not to compress the last action check to "return action3()".

Thanks.

--
Dmitry


\
 
 \ /
  Last update: 2015-10-02 20:21    [W:0.224 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site