]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Initialize couple of variables.
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Mar 2016 08:10:27 +0000 (09:10 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 3 Oct 2016 15:40:08 +0000 (17:40 +0200)
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>
(cherry picked from commit bde6e002b52d110585a0d1618d25878ba177e927)

src/conf/domain_conf.c
src/qemu/qemu_driver.c
src/vbox/vbox_common.c
src/vbox/vbox_tmpl.c

index 2f5c0ed4b7f4a45c097b6fa9b45c89af3d862bed..8999cc6a1bf692320f37d2a1a4c30afe7755ff41 100644 (file)
@@ -13485,7 +13485,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 ae1d8e7ab39708e739acba0b7f1a532242df5404..d1f3079df20551e8eb8cb536311548e8275b9335 100644 (file)
@@ -17017,7 +17017,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 93693671d6f6b381aeca4cd92e71109a6b9e7402..ed06c36b0570413bc4e6ebf396ef8f9542f17392 100644 (file)
@@ -984,7 +984,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 409ecef8bf1801d454a4a97e5c8951c1e8053284..cb29bebb685f00599b4091d7601940381bd91543 100644 (file)
@@ -1037,7 +1037,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] = {};