From: John Ferlan Date: Wed, 27 Aug 2014 20:33:12 +0000 (-0400) Subject: qemu_command: Resolve Coverity DEADCODE X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=84bfb11b69140fbcdb36d7ce1f84489c14a31a02;p=libvirt.git qemu_command: Resolve Coverity DEADCODE One useless warning, but the other one rather pertinent. On entry the 'trans' variable is initialized to VIR_DOMAIN_DISK_TRANS_DEFAULT. When the "trans" was found in the parsing loop it def->geometry.trans was assigned to the return from virDomainDiskGeometryTransTypeFromString and then 'trans' was used to do the comparison to see if it was valid. So remove 'trans' and use def->geometry.trans properly --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 528f947fa5..bf6285f93a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6237,6 +6237,7 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver, def->hyperv_spinlocks); break; + /* coverity[dead_error_begin] */ case VIR_DOMAIN_HYPERV_LAST: break; } @@ -9835,7 +9836,6 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, int idx = -1; int busid = -1; int unitid = -1; - int trans = VIR_DOMAIN_DISK_TRANS_DEFAULT; if (qemuParseKeywords(val, &keywords, @@ -10054,12 +10054,12 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, } else if (STREQ(keywords[i], "trans")) { def->geometry.trans = virDomainDiskGeometryTransTypeFromString(values[i]); - if ((trans < VIR_DOMAIN_DISK_TRANS_DEFAULT) || - (trans >= VIR_DOMAIN_DISK_TRANS_LAST)) { + if ((def->geometry.trans < VIR_DOMAIN_DISK_TRANS_DEFAULT) || + (def->geometry.trans >= VIR_DOMAIN_DISK_TRANS_LAST)) { virDomainDiskDefFree(def); def = NULL; virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse translation value'%s'"), + _("cannot parse translation value '%s'"), values[i]); goto error; }