linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: mantis: remove redundant assignment to variable err
@ 2020-04-10 11:39 Colin King
  2020-04-11 22:53 ` Ezequiel Garcia
  0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2020-04-10 11:39 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable err is being initialized with a value that is never read
and it is being updated later with a new value.  The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/media/pci/mantis/hopper_vp3028.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mantis/hopper_vp3028.c b/drivers/media/pci/mantis/hopper_vp3028.c
index 37bd386f3ed8..ce1e8737b14b 100644
--- a/drivers/media/pci/mantis/hopper_vp3028.c
+++ b/drivers/media/pci/mantis/hopper_vp3028.c
@@ -33,7 +33,7 @@ static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
 {
 	struct i2c_adapter *adapter	= &mantis->adapter;
 	struct mantis_hwconfig *config	= mantis->hwconfig;
-	int err = 0;
+	int err;
 
 	mantis_gpio_set_bits(mantis, config->reset, 0);
 	msleep(100);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: mantis: remove redundant assignment to variable err
  2020-04-10 11:39 [PATCH] media: mantis: remove redundant assignment to variable err Colin King
@ 2020-04-11 22:53 ` Ezequiel Garcia
  2020-04-14  8:59   ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Ezequiel Garcia @ 2020-04-11 22:53 UTC (permalink / raw)
  To: Colin King
  Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors,
	Linux Kernel Mailing List

Hi Colin,

Thanks for your patch!

On Fri, 10 Apr 2020 at 08:39, Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The variable err is being initialized with a value that is never read
> and it is being updated later with a new value.  The initialization is
> redundant and can be removed.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/media/pci/mantis/hopper_vp3028.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/pci/mantis/hopper_vp3028.c b/drivers/media/pci/mantis/hopper_vp3028.c
> index 37bd386f3ed8..ce1e8737b14b 100644
> --- a/drivers/media/pci/mantis/hopper_vp3028.c
> +++ b/drivers/media/pci/mantis/hopper_vp3028.c
> @@ -33,7 +33,7 @@ static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
>  {
>         struct i2c_adapter *adapter     = &mantis->adapter;
>         struct mantis_hwconfig *config  = mantis->hwconfig;
> -       int err = 0;
> +       int err;
>
>         mantis_gpio_set_bits(mantis, config->reset, 0);
>         msleep(100);

There's a redundant err assignment right below here,
which you can also get rid of:

-       err = mantis_frontend_power(mantis, POWER_ON);
+       mantis_frontend_power(mantis, POWER_ON);

I can't test this, but calling mantis_frontend_power twice
is possibly redundant.

Also, what's the gain from this cleanup? The driver is super
old, and it seems any modern compiler would be oblivious
of the redundant assignment.

Thanks!
Ezequiel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: mantis: remove redundant assignment to variable err
  2020-04-11 22:53 ` Ezequiel Garcia
@ 2020-04-14  8:59   ` Dan Carpenter
  2020-04-14  9:11     ` Colin Ian King
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2020-04-14  8:59 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Colin King, Mauro Carvalho Chehab, linux-media, kernel-janitors,
	Linux Kernel Mailing List

On Sat, Apr 11, 2020 at 07:53:51PM -0300, Ezequiel Garcia wrote:
> There's a redundant err assignment right below here,
> which you can also get rid of:
> 
> -       err = mantis_frontend_power(mantis, POWER_ON);
> +       mantis_frontend_power(mantis, POWER_ON);
> 
> I can't test this, but calling mantis_frontend_power twice
> is possibly redundant.

To me that code really looks like a hack-around for flakey hardware and
I would be afraid to delete it.  But the "err =" could be removed.

> 
> Also, what's the gain from this cleanup? The driver is super
> old, and it seems any modern compiler would be oblivious
> of the redundant assignment.

Eventually we would like to enable that warning by default but there are
still thousands of pointless assignments so it will take years of
small fixes like this.  Generally cleaning up warnings is good.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: mantis: remove redundant assignment to variable err
  2020-04-14  8:59   ` Dan Carpenter
@ 2020-04-14  9:11     ` Colin Ian King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin Ian King @ 2020-04-14  9:11 UTC (permalink / raw)
  To: Dan Carpenter, Ezequiel Garcia
  Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors,
	Linux Kernel Mailing List

On 14/04/2020 09:59, Dan Carpenter wrote:
> On Sat, Apr 11, 2020 at 07:53:51PM -0300, Ezequiel Garcia wrote:
>> There's a redundant err assignment right below here,
>> which you can also get rid of:
>>
>> -       err = mantis_frontend_power(mantis, POWER_ON);
>> +       mantis_frontend_power(mantis, POWER_ON);
>>
>> I can't test this, but calling mantis_frontend_power twice
>> is possibly redundant.
> 
> To me that code really looks like a hack-around for flakey hardware and
> I would be afraid to delete it.  But the "err =" could be removed.
> 
>>
>> Also, what's the gain from this cleanup? The driver is super
>> old, and it seems any modern compiler would be oblivious
>> of the redundant assignment.
> 
> Eventually we would like to enable that warning by default but there are
> still thousands of pointless assignments so it will take years of
> small fixes like this.  Generally cleaning up warnings is good.

They are indeed trivial fixes but can allow us to later find real
unassigned variable bugs in the future when new code gets added and does
not set these variables.

Colin
> 
> regards,
> dan carpenter
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-14  9:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 11:39 [PATCH] media: mantis: remove redundant assignment to variable err Colin King
2020-04-11 22:53 ` Ezequiel Garcia
2020-04-14  8:59   ` Dan Carpenter
2020-04-14  9:11     ` Colin Ian King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).