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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]