[libvirt] [PATCH 0/3] Resolve DEADCODE errors found by Coverity

This set of patches resolves "Error: DEADCODE (CWE-561)" errors found by Coverity John Ferlan (3): phyp: Remove deadcode referencing exit_status nwfilter: Remove unprivileged code path to set base tests: Remove remnants of removing the fake emulator output src/nwfilter/nwfilter_driver.c | 10 ++-------- src/phyp/phyp_driver.c | 4 ---- tests/qemuxml2argvtest.c | 11 ----------- 3 files changed, 2 insertions(+), 23 deletions(-) -- 1.7.11.7

Remove remnants from commit id '89144534' --- src/phyp/phyp_driver.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 2dabd19..f89871f 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3329,7 +3329,6 @@ phypDomainLookupByID(virConnectPtr conn, int lpar_id) LIBSSH2_SESSION *session = connection_data->session; virDomainPtr dom = NULL; char *managed_system = phyp_driver->managed_system; - int exit_status = 0; unsigned char lpar_uuid[VIR_UUID_BUFLEN]; char *lpar_name = phypGetLparNAME(session, managed_system, lpar_id, @@ -3338,9 +3337,6 @@ phypDomainLookupByID(virConnectPtr conn, int lpar_id) if (phypGetLparUUID(lpar_uuid, lpar_id, conn) == -1) goto cleanup; - if (exit_status < 0) - goto cleanup; - dom = virGetDomain(conn, lpar_name, lpar_uuid); if (dom) -- 1.7.11.7

On 01/08/2013 02:21 PM, John Ferlan wrote:
Remove remnants from commit id '89144534'
'git blame' points squarely to me :)
--- src/phyp/phyp_driver.c | 4 ---- 1 file changed, 4 deletions(-)
ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Commit id f8ab364c removed ability to run this driver unprivileged. Coverity detected the check and flagged it. --- src/nwfilter/nwfilter_driver.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 1ac91cf..815f588 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -219,14 +219,8 @@ nwfilterDriverStartup(bool privileged ATTRIBUTE_UNUSED, goto error; } - if (privileged) { - if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL) - goto out_of_memory; - } else { - base = virGetUserConfigDirectory(); - if (!base) - goto error; - } + if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL) + goto out_of_memory; if (virAsprintf(&driverState->configDir, "%s/nwfilter", base) == -1) -- 1.7.11.7

On 01/08/2013 02:21 PM, John Ferlan wrote:
Commit id f8ab364c removed ability to run this driver unprivileged. Coverity detected the check and flagged it. --- src/nwfilter/nwfilter_driver.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Coverity determined that 'emulator' could no longer be set and determined the code was dead. Looking through the history, I discovered commit-id ed769e18 removed code originally added by commit-id 9237e955 and further modified by commit-id 6a7e7c4f. --- tests/qemuxml2argvtest.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b6e99db..31ed116 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -91,7 +91,6 @@ static int testCompareXMLToArgvFiles(const char *xml, virDomainChrSourceDef monitor_chr; virConnectPtr conn; char *log = NULL; - char *emulator = NULL; virCommandPtr cmd = NULL; if (!(conn = virGetConnect())) @@ -173,15 +172,6 @@ static int testCompareXMLToArgvFiles(const char *xml, if (!(actualargv = virCommandToString(cmd))) goto out; - if (emulator) { - /* Skip the abs_srcdir portion of replacement emulator. */ - char *start_skip = strstr(actualargv, abs_srcdir); - char *end_skip = strstr(actualargv, emulator); - if (!start_skip || !end_skip) - goto out; - memmove(start_skip, end_skip, strlen(end_skip) + 1); - } - len = virtTestLoadFile(cmdline, &expectargv); if (len < 0) goto out; @@ -203,7 +193,6 @@ static int testCompareXMLToArgvFiles(const char *xml, out: VIR_FREE(log); - VIR_FREE(emulator); VIR_FREE(expectargv); VIR_FREE(actualargv); virCommandFree(cmd); -- 1.7.11.7

On 01/08/2013 02:21 PM, John Ferlan wrote:
Coverity determined that 'emulator' could no longer be set and determined the code was dead. Looking through the history, I discovered commit-id ed769e18 removed code originally added by commit-id 9237e955 and further modified by commit-id 6a7e7c4f.
Thanks again for digging up the history behind the code. That makes it so much easier to explain why we are fixing things by deletions.
--- tests/qemuxml2argvtest.c | 11 ----------- 1 file changed, 11 deletions(-)
Always fun to have a patch with pure deletion :) ACK, and series pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
John Ferlan