From: Ian Jackson Date: Mon, 29 Jun 2015 14:29:33 +0000 (+0100) Subject: libxl: Fix uninitialised rc in libxl__domain_save_device_model X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2982 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e00ab5e0770ccd458211d6fe5b679e15f8d66bcf;p=xen.git libxl: Fix uninitialised rc in libxl__domain_save_device_model 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 Signed-off-by: Ian Jackson Tested-by: Andrew Cooper --- diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index bdc04657fa..1c9418ab90 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -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; }