[PATCH] build: avoid unused variable warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* src/vbox/vbox_tmpl.c (vboxAttachDrives): Capture return value.
---

Pushing under the build-breaker rule.  Gcc didn't catch this under
'-g -O0', but with -Werror and -O2, it dies with a warning that rc
is used uninitialized.  I suspect that clang would have also
reported this, although I haven't tested that suspicion.

This was a pre-existing bug; my refactoring exposed it (before the
refactoring, rc contained stale contents, unrelated to the actual
message being printed; after the refactoring, rc was indeed used
without initialization).

 src/vbox/vbox_tmpl.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 3e8ff23..b5cd2e4 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -3788,40 +3788,42 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
                 VBOX_UTF16_FREE(mediumFileUtf16);
                 continue;
             }

             if (!medium) {
                 PRUnichar *mediumEmpty = NULL;

                 VBOX_UTF8_TO_UTF16("", &mediumEmpty);

                 if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
-                    data->vboxObj->vtbl->OpenHardDisk(data->vboxObj,
-                                                      mediumFileUtf16,
-                                                      AccessMode_ReadWrite,
-                                                      false,
-                                                      mediumEmpty,
-                                                      false,
-                                                      mediumEmpty,
-                                                      &medium);
+                    rc = data->vboxObj->vtbl->OpenHardDisk(data->vboxObj,
+                                                           mediumFileUtf16,
+                                                           AccessMode_ReadWrite,
+                                                           false,
+                                                           mediumEmpty,
+                                                           false,
+                                                           mediumEmpty,
+                                                           &medium);
                 } else if (def->disks[i]->device ==
                            VIR_DOMAIN_DISK_DEVICE_CDROM) {
-                    data->vboxObj->vtbl->OpenDVDImage(data->vboxObj,
-                                                      mediumFileUtf16,
-                                                      mediumEmpty,
-                                                      &medium);
+                    rc = data->vboxObj->vtbl->OpenDVDImage(data->vboxObj,
+                                                           mediumFileUtf16,
+                                                           mediumEmpty,
+                                                           &medium);
                 } else if (def->disks[i]->device ==
                            VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
-                    data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
-                                                         mediumFileUtf16,
-                                                         mediumEmpty,
-                                                         &medium);
+                    rc = data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
+                                                              mediumFileUtf16,
+                                                              mediumEmpty,
+                                                              &medium);
+                } else {
+                    rc = 0;
                 }

                 VBOX_UTF16_FREE(mediumEmpty);
             }

             if (!medium) {
                 vboxError(VIR_ERR_INTERNAL_ERROR,
                           _("Failed to attach the following disk/dvd/floppy "
                             "to the machine: %s, rc=%08x"),
                           def->disks[i]->src, (unsigned)rc);
-- 
1.7.2.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]