All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	Roger Pau Monne <roger.pau@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH] libxc: initialise rc to -1 at the beginning of meminit_hvm
Date: Thu, 3 Mar 2016 15:59:11 +0000	[thread overview]
Message-ID: <20160303155911.GJ5535@citrix.com> (raw)
In-Reply-To: <22232.23631.403457.935901@mariner.uk.xensource.com>

On Thu, Mar 03, 2016 at 03:46:23PM +0000, Ian Jackson wrote:
> Wei Liu writes ("[PATCH] libxc: initialise rc to -1 at the beginning of meminit_hvm"):
> > Variable rc is only set either inside a loop or inside some if
> > statements. To avoid confuse gcc with stricter setting we set rc to -1
> > at the beginning.
> 
> Is this really the best way to fix this ?
> 
> AFAICT the problem arises only for this code:
> 
>     if ( rc != 0 )
>     {
>         DOMPRINTF("Could not allocate memory for HVM guest.");
>         goto error_out;
>     }
> 
> which occurs after the loop.  But that path happens only if
> 
>         if ( rc != 0 )
>             break;
> 
> is executed inside the loop.
> 
> If the error case was moved into the loop, there would be no need for
> the separate test of rc (which is confusing to humans as well as to
> the compiler).
> 
> Do you agree ?
> 

Yes, that's better.

I will send v2 shortly.

Wei.

> Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

      reply	other threads:[~2016-03-03 15:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 15:30 [PATCH] libxc: initialise rc to -1 at the beginning of meminit_hvm Wei Liu
2016-03-03 15:46 ` Ian Jackson
2016-03-03 15:59   ` Wei Liu [this message]

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=20160303155911.GJ5535@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.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.