[libvirt] [PATCH 3/3] qemu: Split if condition in qemuDomainSnapshotUndoSingleDiskActive

Eric Blake eblake at redhat.com
Fri Apr 13 12:15:24 UTC 2012


On 04/13/2012 03:39 AM, Daniel P. Berrange wrote:
> On Fri, Apr 13, 2012 at 11:12:54AM +0200, Michal Privoznik wrote:
>> Since compilers are trying to optimize code they are allowed to
>> reorder evaluation of conditions in if statement (okay, not in all
>> cases, but they can in this one). Therefore if we do:
>>     if (stat(file, &st) == 0 && unlink(file) < 0)
>> after compiler chews this it may get feeling that swapping order
>> is a good idea. However, we obviously don't want to call stat()
>> on just unlink()-ed file.
> 
> Really ? I'm not sure I believe that. IIRC in-order short-circuit
> evaluation is a part of the C standard. Compilers can't do any
> optimization which changes the order of evalation without breaking
> countless C programs.

I concur - NACK to this patch.  Any C compiler that violates
short-circuiting semantics is too severely broken to be worth working
around in our code.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120413/75af4d46/attachment-0001.sig>


More information about the libvir-list mailing list