From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] tools/libxl: Fix build following c/s c3c8da9 Date: Mon, 29 Jun 2015 15:22:47 +0100 Message-ID: <559154B7.8030708@citrix.com> References: <1435581680-11989-1-git-send-email-andrew.cooper3@citrix.com> <21905.20904.334921.585121@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21905.20904.334921.585121@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Wei Liu , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org On 29/06/15 15:09, Ian Jackson wrote: > Andrew Cooper writes ("[PATCH] tools/libxl: Fix build following c/s c3c8da9"): >> c/s 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, which is cause by GCC 4.8's -Wmaybe-uninitialized > The solution is not to initialise rc (to a bogus value) but to fix the > goto out paths to explicitly set rc. > > Can you easily confirm that this fixes it ? It does indeed. Tested-by: Andrew Cooper However, the problem with this style is that it is subverted by: rc = libxl__datacopier_start(dc); if (rc) goto out; out of context below, which cases rc to be initialised on all subsequent error paths, and thus miss further issues where it is set incorrectly. I would suggest introducing another int to hold the temporary from libxl__datacopier_start(). ~Andrew > > Ian. > > diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c > index bdc0465..1c9418a 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; > } >