]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: fix uninitialized variable warning
authorChristophe Fergeau <cfergeau@redhat.com>
Mon, 2 May 2011 09:10:10 +0000 (11:10 +0200)
committerEric Blake <eblake@redhat.com>
Mon, 2 May 2011 15:23:47 +0000 (09:23 -0600)
This commit fixes
qemu/qemu_driver.c: In function 'qemuDomainModifyDeviceFlags':
qemu/qemu_driver.c:4041:8: warning: 'ret' may be used uninitialized in this
function [-Wuninitialized]
qemu/qemu_driver.c:4013:9: note: 'ret' was declared here

The variable is set to -1 so that the error paths are taken when the code
to set it didn't get a chance to run. Without initializing it, we could
return some an undefined value from this function.

While I was at it, I made a trivial whitespace change in the same function
to improve readability.

src/qemu/qemu_driver.c

index a19c4a781ef0d4f8570e37c89e0b7b61f0d154ef..16d869d4cbcdb277fb733ec30ec1a6b62f6927c9 100644 (file)
@@ -4010,11 +4010,11 @@ qemuDomainChangeDiskMediaLive(virDomainObjPtr vm,
 {
     virDomainDiskDefPtr disk = dev->data.disk;
     virCgroupPtr cgroup = NULL;
-    int ret;
+    int ret = -1;
 
     if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_DEVICES)) {
         if (virCgroupForDomain(driver->cgroup,
-                               vm->def->name, &cgroup, 0) !=) {
+                               vm->def->name, &cgroup, 0) != 0) {
             qemuReportError(VIR_ERR_INTERNAL_ERROR,
                             _("Unable to find cgroup for %s"),
                             vm->def->name);