[libvirt] [PATCH] qemu_hotplug: Resolve DEADCODE coverity error

Remove unused 'cgroup' variable in qemuDomainAttachDeviceDiskLive() to resolve coverity DEADCODE complaint --- Refactoring of qemuDomainAttachDeviceDiskLive() in the following patch: https://www.redhat.com/archives/libvir-list/2013-August/msg00079.html seemed to wake up Coverity and it complained about deadcode as a result of 'cgroup' only ever been NULL thus the check for it to be non-NULL in order to call qemuTeardownDiskCgroup() would not be able to occur. The code actually hadn't changed, but for some reason coverity now found it. Followed example in qemuDomainChangeDiskMediaLive() and just removed the 'cgroup' variable. src/qemu/qemu_hotplug.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9c655ff..6cdee44 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -683,7 +683,6 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, virDomainDiskDefPtr orig_disk = NULL; virDomainDeviceDefPtr dev_copy = NULL; virDomainDiskDefPtr tmp = NULL; - virCgroupPtr cgroup = NULL; virCapsPtr caps = NULL; int ret = -1; @@ -773,10 +772,10 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, break; } - if (ret != 0 && cgroup) { - if (qemuTeardownDiskCgroup(vm, disk) < 0) - VIR_WARN("Failed to teardown cgroup for disk path %s", - NULLSTR(disk->src)); + if (ret != 0 && + qemuTeardownDiskCgroup(vm, disk) < 0) { + VIR_WARN("Failed to teardown cgroup for disk path %s", + NULLSTR(disk->src)); } end: -- 1.8.3.1

On 08/31/2013 05:24 AM, John Ferlan wrote:
Remove unused 'cgroup' variable in qemuDomainAttachDeviceDiskLive() to resolve coverity DEADCODE complaint
---
src/qemu/qemu_hotplug.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
ACK, worth having in 1.1.2. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/31/2013 07:24 AM, John Ferlan wrote:
Remove unused 'cgroup' variable in qemuDomainAttachDeviceDiskLive() to resolve coverity DEADCODE complaint
--- Refactoring of qemuDomainAttachDeviceDiskLive() in the following patch:
https://www.redhat.com/archives/libvir-list/2013-August/msg00079.html
seemed to wake up Coverity and it complained about deadcode as a result of 'cgroup' only ever been NULL thus the check for it to be non-NULL in order to call qemuTeardownDiskCgroup() would not be able to occur. The code actually hadn't changed, but for some reason coverity now found it.
Followed example in qemuDomainChangeDiskMediaLive() and just removed the 'cgroup' variable.
src/qemu/qemu_hotplug.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
Pushed. John
participants (2)
-
Eric Blake
-
John Ferlan