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

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

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

Attachment: signature.asc
Description: OpenPGP digital signature

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