]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: Fix uninitialised rc in libxl__domain_save_device_model
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 29 Jun 2015 14:29:33 +0000 (15:29 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 29 Jun 2015 14:29:33 +0000 (15:29 +0100)
c3c8da9 "libxl: ao: datacopier callback gets an rc" caused
libxl__domain_save_device_model() to pass its rc directly into the
callback.

However in the preexisting code, there were 3 "goto out;" paths which
left rc uninitialised.  This causes a build failure with GCC 4.8's
-Wmaybe-uninitialized.

Set the rc explicitly on each goto out path.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxl/libxl_dom.c

index bdc04657fae846f6721e2ce824fd3ef7bf685b01..1c9418ab9074af0395a662c5d580632bd5c72d06 100644 (file)
@@ -2190,17 +2190,20 @@ void libxl__domain_save_device_model(libxl__egc *egc,
     dc->readfd = open(filename, O_RDONLY);
     if (dc->readfd < 0) {
         LOGE(ERROR, "unable to open %s", dc->readwhat);
+        rc = ERROR_FAIL;
         goto out;
     }
 
     if (fstat(dc->readfd, &st))
     {
         LOGE(ERROR, "unable to fstat %s", dc->readwhat);
+        rc = ERROR_FAIL;
         goto out;
     }
 
     if (!S_ISREG(st.st_mode)) {
         LOG(ERROR, "%s is not a plain file!", dc->readwhat);
+        rc = ERROR_FAIL;
         goto out;
     }