[PATCH-for-5.0 04/11] hw/input/adb-kbd: Remove dead assignment

Philippe Mathieu-Daudé posted 11 patches 5 years, 10 months ago
Maintainers: Andrew Jeffery <andrew@aj.id.au>, David Gibson <david@gibson.dropbear.id.au>, Alistair Francis <alistair@alistair23.me>, "Cédric Le Goater" <clg@kaod.org>, Andrzej Zaborowski <balrogg@gmail.com>, Fam Zheng <fam@euphon.net>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, John Snow <jsnow@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Joel Stanley <joel@jms.id.au>, Paolo Bonzini <pbonzini@redhat.com>, Igor Mitsyanko <i.mitsyanko@gmail.com>, Markus Armbruster <armbru@redhat.com>, BALATON Zoltan <balaton@eik.bme.hu>, Peter Maydell <peter.maydell@linaro.org>, "Hervé Poussineau" <hpoussin@reactos.org>, Max Reitz <mreitz@redhat.com>
There is a newer version of this series
[PATCH-for-5.0 04/11] hw/input/adb-kbd: Remove dead assignment
Posted by Philippe Mathieu-Daudé 5 years, 10 months ago
Fix warning reported by Clang static code analyzer:

    CC      hw/input/adb-kbd.o
  hw/input/adb-kbd.c:200:5: warning: Value stored to 'olen' is never read
      olen = 0;
      ^      ~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/input/adb-kbd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
index 0ba8207589..b0565be21b 100644
--- a/hw/input/adb-kbd.c
+++ b/hw/input/adb-kbd.c
@@ -197,7 +197,6 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf)
     int keycode;
     int olen;
 
-    olen = 0;
     if (s->count == 0) {
         return 0;
     }
-- 
2.21.1


Re: [PATCH-for-5.0 04/11] hw/input/adb-kbd: Remove dead assignment
Posted by BALATON Zoltan 5 years, 10 months ago
On Sat, 21 Mar 2020, Philippe Mathieu-Daudé wrote:
> Fix warning reported by Clang static code analyzer:
>
>    CC      hw/input/adb-kbd.o
>  hw/input/adb-kbd.c:200:5: warning: Value stored to 'olen' is never read
>      olen = 0;
>      ^      ~
>
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/input/adb-kbd.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
> index 0ba8207589..b0565be21b 100644
> --- a/hw/input/adb-kbd.c
> +++ b/hw/input/adb-kbd.c
> @@ -197,7 +197,6 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf)
>     int keycode;
>     int olen;
>
> -    olen = 0;
>     if (s->count == 0) {
>         return 0;
>     }

Is this variable still needed at all? Looks like it's a remnant after 
a1f4971863 that can now only return 0 or 2 so you could just remove this 
variable and return 2 where now it's assigned as 2 or change return olen 
at the end to return 2 or maybe keep olen and change the return 0 above to 
return olen to silence warning but I think this could be cleaned up.

Regards,
BALATON Zoltan