Re: [PATCH] qemu: Resolve Coverity DEADCODE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27.04.2015 13:33, John Ferlan wrote:
> Coverity notes taht the switch() used to check 'connected' values has

s/taht/that/

> two DEADCODE paths (_DEFAULT & _LAST).  Since 'connected' is a boolean
> it can only be one or the other (CONNECTED or DISCONNECTED), so it just
> seems pointless to use a switch to get "all" values.  Convert to if-else
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 31cbccb..1c72844 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -4497,8 +4497,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
>          goto endjob;
>  
>      if (STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0")) {
> -        switch (newstate) {
> -        case VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED:
> +        if (newstate == VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED) {
>              if (!priv->agent) {
>                  if ((rc = qemuConnectAgent(driver, vm)) == -2)
>                      goto endjob;
> @@ -4506,20 +4505,13 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
>                  if (rc < 0)
>                      priv->agentError = true;
>              }
> -            break;
> -
> -        case VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED:
> +        } else {
>              if (priv->agent) {
>                  qemuAgentClose(priv->agent);
>                  priv->agent = NULL;
>                  priv->agentError = false;
>              }
> -            break;
> -
> -        case VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT:
> -        case VIR_DOMAIN_CHR_DEVICE_STATE_LAST:
> -            break;

Can't we just put coverity[dead_error_begin] or something similar here?

> -        };
> +        }
>  
>          if ((event = virDomainEventAgentLifecycleNewFromObj(vm, newstate,
>                                                              VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_CHANNEL)))
> 

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]