[Qemu-devel] [PATCH for 3.0] sm501: Fix warning about unreachable code

BALATON Zoltan posted 1 patch 7 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180715211731.311B67456B5@zero.eik.bme.hu
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
hw/display/sm501.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH for 3.0] sm501: Fix warning about unreachable code
Posted by BALATON Zoltan 7 years, 3 months ago
Coverity warned that the false arm of conditional expression is
unreachable when it is inside an if with the same condition.
Remove the unreachable code to avoid the warning.

Fixes: CID 1394215
Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/display/sm501.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 9ab29d3..874260a 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -1024,7 +1024,7 @@ static void sm501_i2c_write(void *opaque, hwaddr addr, uint64_t value,
                         if (res) {
                             SM501_DPRINTF("sm501 i2c : transfer failed"
                                           " i=%d, res=%d\n", i, res);
-                            s->i2c_status |= (res ? SM501_I2C_STATUS_ERROR : 0);
+                            s->i2c_status |= SM501_I2C_STATUS_ERROR;
                             return;
                         }
                     }
-- 
2.7.6


Re: [Qemu-devel] [PATCH for 3.0] sm501: Fix warning about unreachable code
Posted by Philippe Mathieu-Daudé 7 years, 3 months ago
On 07/15/2018 05:59 PM, BALATON Zoltan wrote:
> Coverity warned that the false arm of conditional expression is
> unreachable when it is inside an if with the same condition.
> Remove the unreachable code to avoid the warning.
> 
> Fixes: CID 1394215
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  hw/display/sm501.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 9ab29d3..874260a 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -1024,7 +1024,7 @@ static void sm501_i2c_write(void *opaque, hwaddr addr, uint64_t value,
>                          if (res) {
>                              SM501_DPRINTF("sm501 i2c : transfer failed"
>                                            " i=%d, res=%d\n", i, res);
> -                            s->i2c_status |= (res ? SM501_I2C_STATUS_ERROR : 0);
> +                            s->i2c_status |= SM501_I2C_STATUS_ERROR;
>                              return;
>                          }
>                      }
> 

Re: [Qemu-devel] [PATCH for 3.0] sm501: Fix warning about unreachable code
Posted by David Gibson 7 years, 3 months ago
On Sun, Jul 15, 2018 at 10:59:21PM +0200, BALATON Zoltan wrote:
> Coverity warned that the false arm of conditional expression is
> unreachable when it is inside an if with the same condition.
> Remove the unreachable code to avoid the warning.
> 
> Fixes: CID 1394215
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>

Applied to ppc-for-3.0, thanks.

> ---
>  hw/display/sm501.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 9ab29d3..874260a 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -1024,7 +1024,7 @@ static void sm501_i2c_write(void *opaque, hwaddr addr, uint64_t value,
>                          if (res) {
>                              SM501_DPRINTF("sm501 i2c : transfer failed"
>                                            " i=%d, res=%d\n", i, res);
> -                            s->i2c_status |= (res ? SM501_I2C_STATUS_ERROR : 0);
> +                            s->i2c_status |= SM501_I2C_STATUS_ERROR;
>                              return;
>                          }
>                      }

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson