[libvirt] [PATCH] qemu: initialize variables in qemuParseCommandLine

Ján Tomko posted 1 patch 5 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/ea119118fc9e477aaafa1968449c0ffd22d7d84c.1535453718.git.jtomko@redhat.com
Test syntax-check passed
src/qemu/qemu_parse_command.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[libvirt] [PATCH] qemu: initialize variables in qemuParseCommandLine
Posted by Ján Tomko 5 years, 8 months ago
Commit 6700062 introduced a jump to error which skipped the
initialization of def:

qemu/qemu_parse_command.c:1870:9: error: variable 'def' is
used uninitialized whenever 'if' condition is true
      [-Werror,-Wsometimes-uninitialized]
    if (!(qemuCaps = virQEMUCapsCacheLookup(capsCache, progargv[0])))

Initialize def to fix this warning and qemuCaps, to prevent
a future error like this.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
Pushed as a build breaker fix.

 src/qemu/qemu_parse_command.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index c0bf27f800..5b4a378a18 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1838,7 +1838,7 @@ qemuParseCommandLine(virFileCachePtr capsCache,
                      virDomainChrSourceDefPtr *monConfig,
                      bool *monJSON)
 {
-    virDomainDefPtr def;
+    virDomainDefPtr def = NULL;
     size_t i;
     bool nographics = false;
     bool fullscreen = false;
@@ -1852,7 +1852,7 @@ qemuParseCommandLine(virFileCachePtr capsCache,
     virDomainDiskDefPtr disk = NULL;
     const char *ceph_args = qemuFindEnv(progenv, "CEPH_ARGS");
     bool have_sdl = false;
-    virQEMUCapsPtr qemuCaps;
+    virQEMUCapsPtr qemuCaps = NULL;
 
     if (pidfile)
         *pidfile = NULL;
-- 
2.16.4

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