Re: [PATCH 06/34] [media] DaVinci-VPBE: Return an error code only by a single variable in vpbe_initialize()
From: Mauro Carvalho Chehab
Date: Wed Nov 16 2016 - 09:31:05 EST
Em Wed, 12 Oct 2016 16:40:22 +0200
SF Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> escreveu:
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Tue, 11 Oct 2016 14:15:57 +0200
>
> An error code was assigned to the local variable "err" in an if branch.
> But this variable was not used further then.
>
> Use the local variable "ret" instead like at other places in this function.
>
> Fixes: 66715cdc3224a4e241c1a92856b9a4af3b70e06d ("[media] davinci vpbe:
> VPBE display driver")
> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/media/platform/davinci/vpbe.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
> index 4c4cd81..afa8ff7 100644
> --- a/drivers/media/platform/davinci/vpbe.c
> +++ b/drivers/media/platform/davinci/vpbe.c
> @@ -665,7 +665,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
> if (err) {
> v4l2_err(&vpbe_dev->v4l2_dev,
> "unable to initialize the OSD device");
> - err = -ENOMEM;
> + ret = -ENOMEM;
> goto fail_dev_unregister;
> }
> }
Hmm... why are you keeping both "err" and "ret" variables here?
Just one var is needed. Also, why not just return the error code?
If you want to cleanup the code, please look at the entire function,
and not to just this occurrence.
I mean, IMHO, this code (and all similar occurrences), should be, instead:
ret = osd_device->ops.initialize(osd_device);
if (ret) {
v4l2_err(&vpbe_dev->v4l2_dev,
"unable to initialize the OSD device");
goto fail_dev_unregister;
}
and the "err" var can probably be removed.
Thanks,
Mauro