[libvirt] [PATCH] build: work around gcc 6.0 warnings

Michal Privoznik mprivozn at redhat.com
Thu Feb 25 14:01:29 UTC 2016


On 25.02.2016 14:48, Eric Blake wrote:
> On 02/25/2016 04:15 AM, Pavel Hrdina wrote:
>> On Wed, Feb 24, 2016 at 02:29:58PM -0700, Eric Blake wrote:
>>> gcc 6.0 added an annoying warning:
>>>
>>> fdstream.c: In function 'virFDStreamWrite':
>>> fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
>>>         if (errno == EAGAIN || errno == EWOULDBLOCK) {
>>>                             ^~
>>> fdstream.c: In function 'virFDStreamRead':
>>> fdstream.c:440:29: error: logical 'or' of equal expressions [-Werror=logical-op]
>>>         if (errno == EAGAIN || errno == EWOULDBLOCK) {
>>>                             ^~
>>>
>>> This makes it impossible to build out-of-the-box on rawhide,
>>> and we aren't guaranteed that the gcc bug will be fixed in a
>>> timely manner:
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602
>>>
>>> So work around it by further complicating the logic to thwart the
>>> compiler.
>>
>> Personally I don't like this approach.  Why don't we take that 6 line reproducer
>> from GCC BZ and create a m4 macro that will detect that bug in GCC and turn off
>> the logical-op check?  For me this solution is much cleaner than introducing
>> some ugly workaround in our code just because GCC has a bug.
> 
> Killing it for the entire tree seems like a rather heavy hammer.  I'd
> rather just add #pragma push/pop to ignore the warning around the few
> places that it incorrectly triggers, leaving the rest of the tree still
> protected (as it does catch real bugs, when we aren't dealing with
> sometimes-aliased values coming from headers).

Since not everybody is switching to gcc 6.0 (I'm stuck with 4.9.3 for a
while now) we are still going to be able to catch those errors.
Moreover, if the gcc bug is ever fixed we don't need to undo those pragmas.

Michal




More information about the libvir-list mailing list