All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] tools/libxl: Fix build following c/s c3c8da9
Date: Mon, 29 Jun 2015 15:22:47 +0100	[thread overview]
Message-ID: <559154B7.8030708@citrix.com> (raw)
In-Reply-To: <21905.20904.334921.585121@mariner.uk.xensource.com>

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 <andrew.cooper3@citrix.com>

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;
>      }
>  

  reply	other threads:[~2015-06-29 14:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-29 12:41 [PATCH] tools/libxl: Fix build following c/s c3c8da9 Andrew Cooper
2015-06-29 14:09 ` Ian Jackson
2015-06-29 14:22   ` Andrew Cooper [this message]
2015-06-29 14:29     ` Ian Jackson
2015-06-29 14:32       ` [PATCH] libxl: Fix uninitialised rc in libxl__domain_save_device_model Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559154B7.8030708@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.