]> xenbits.xensource.com Git - libvirt.git/commitdiff
Initialize couple of variables.
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Mar 2016 08:10:27 +0000 (09:10 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Mar 2016 13:39:57 +0000 (14:39 +0100)
While trying to build with -Os couple of compile errors showed
up.

conf/domain_conf.c: In function 'virDomainChrRemove':
conf/domain_conf.c:13666:24: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virDomainChrDefPtr ret, **arrPtr = NULL;
                        ^
Compiler fails to see that @ret is used only if set in the loop,
but whatever, there's no harm in initializing the variable.

In vboxAttachDrivesNew and _vboxAttachDrivesOld compiler thinks
that @rc may be used uninitialized. Well, not directly, but maybe
after some optimization. Yet again, no harm in initializing a
variable.

In file included from ./util/virthread.h:26:0,
                 from ./datatypes.h:28,
                 from vbox/vbox_tmpl.c:43,
                 from vbox/vbox_V3_1.c:37:
vbox/vbox_tmpl.c: In function '_vboxAttachDrivesOld':
./util/virerror.h:181:5: error: 'rc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virReportErrorHelper(VIR_FROM_THIS, code, __FILE__,              \
     ^
In file included from vbox/vbox_V3_1.c:37:0:
vbox/vbox_tmpl.c:1041:14: note: 'rc' was declared here
     nsresult rc;
              ^
Yet again, one uninitialized variable:

qemu/qemu_driver.c: In function 'qemuDomainBlockCommit':
qemu/qemu_driver.c:17194:9: error: 'baseSource' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         qemuDomainPrepareDiskChainElement(driver, vm, baseSource,
         ^

And another one:

storage/storage_backend_logical.c: In function 'virStorageBackendLogicalMatchPoolSource.isra.2':
storage/storage_backend_logical.c:618:33: error: 'thisSource' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                       thisSource->devices[j].path))
                                 ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
src/qemu/qemu_driver.c
src/storage/storage_backend_logical.c
src/vbox/vbox_common.c
src/vbox/vbox_tmpl.c

index 8bfe895d5ce5ee473f8709592f2e7bec296ded84..39cedbd46eabac140cb5de7181d8552ab5424cdd 100644 (file)
@@ -13663,7 +13663,7 @@ virDomainChrDefPtr
 virDomainChrRemove(virDomainDefPtr vmdef,
                    virDomainChrDefPtr chr)
 {
-    virDomainChrDefPtr ret, **arrPtr = NULL;
+    virDomainChrDefPtr ret = NULL, **arrPtr = NULL;
     size_t i, *cntPtr = NULL;
 
     virDomainChrGetDomainPtrsInternal(vmdef, chr->deviceType, &arrPtr, &cntPtr);
index 9fd4c570cd589618107ef88c646634b58dd5e76c..102fade2806891873723a79b06f49be6b4224efe 100644 (file)
@@ -16988,7 +16988,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
     virDomainDiskDefPtr disk = NULL;
     virStorageSourcePtr topSource;
     unsigned int topIndex = 0;
-    virStorageSourcePtr baseSource;
+    virStorageSourcePtr baseSource = NULL;
     unsigned int baseIndex = 0;
     virStorageSourcePtr top_parent = NULL;
     bool clean_access = false;
index 167fe58d7ef7fa93b75366f741b3cebaa0878d79..ecbf43054428ff1b5fc57d48987c2a4a087b6920 100644 (file)
@@ -575,7 +575,7 @@ static bool
 virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
 {
     virStoragePoolSourceList sourceList;
-    virStoragePoolSource *thisSource;
+    virStoragePoolSource *thisSource = NULL;
     size_t i, j;
     int matchcount = 0;
     bool ret = false;
index 8c00a4f5b77a35fb51c208f62647ef5fd9db5d54..0152b353b04a47b2f3d0813e5eafdb70d895c1f5 100644 (file)
@@ -987,7 +987,7 @@ vboxAttachDrivesNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine
 {
     /* AttachDrives for 3.0 and later */
     size_t i;
-    nsresult rc;
+    nsresult rc = 0;
     PRUint32 maxPortPerInst[StorageBus_Floppy + 1] = {};
     PRUint32 maxSlotPerPort[StorageBus_Floppy + 1] = {};
     PRUnichar *storageCtlName = NULL;
index cc86bf787e205545a3040d7cb1a1042fa71e17bc..0fbd5b32970bae2ce3876cb6b99a4e984b833012 100644 (file)
@@ -1038,7 +1038,7 @@ static void
 _vboxAttachDrivesOld(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
 {
     size_t i;
-    nsresult rc;
+    nsresult rc = 0;
 
     PRUint32 maxPortPerInst[StorageBus_Floppy + 1] = {};
     PRUint32 maxSlotPerPort[StorageBus_Floppy + 1] = {};