|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] libxc: initialise rc to -1 at the beginning of meminit_hvm
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@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |