提交 d8082d2d 编写于 作者: J John Ferlan

qemu: Resolve Coverity DEADCODE

Coverity notes that the switch() used to check 'connected' values has
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
上级 1f7e8112
...@@ -4497,8 +4497,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver, ...@@ -4497,8 +4497,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
goto endjob; goto endjob;
if (STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0")) { if (STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0")) {
switch (newstate) { if (newstate == VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED) {
case VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED:
if (!priv->agent) { if (!priv->agent) {
if ((rc = qemuConnectAgent(driver, vm)) == -2) if ((rc = qemuConnectAgent(driver, vm)) == -2)
goto endjob; goto endjob;
...@@ -4506,20 +4505,13 @@ processSerialChangedEvent(virQEMUDriverPtr driver, ...@@ -4506,20 +4505,13 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
if (rc < 0) if (rc < 0)
priv->agentError = true; priv->agentError = true;
} }
break; } else {
case VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED:
if (priv->agent) { if (priv->agent) {
qemuAgentClose(priv->agent); qemuAgentClose(priv->agent);
priv->agent = NULL; priv->agent = NULL;
priv->agentError = false; priv->agentError = false;
} }
break; }
case VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT:
case VIR_DOMAIN_CHR_DEVICE_STATE_LAST:
break;
};
if ((event = virDomainEventAgentLifecycleNewFromObj(vm, newstate, if ((event = virDomainEventAgentLifecycleNewFromObj(vm, newstate,
VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_CHANNEL))) VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_CHANNEL)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册