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

Re: [Xen-devel] [PATCH] x86/dom0-build: fix build with clang5


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <JBeulich@xxxxxxxx>
  • Date: Mon, 15 Jul 2019 14:19:07 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CYyKQJ1g3L0c31d4ozKIE6vP7E7RlE1nVxEVajYRz2c=; b=LFAAvn2qRqQZwLk6ZyajCrT55pFMEQnCRa0HPrfbYxrwW3HF2V4rcvgS+mi3fCYX4Z0Iw7mfYQshNLNvcvISFsOvFdXvjGnoNf0RuV0ZQ/NS2aON1QLX6sTFAgAGHygx3tAPcjPbRER5cCaKx0dcPHMq05E3ce+vKwQaRfNh8F05HWx4zna5EGUeHC6QTK3+r6Mq07mvUhaWrJ3daXcPdBiGkEmekZ8kopmYH1pbwfN6LrEM28MSAehQdBBestnqKQNGBdwGY3nP/9j8KNZXumFaDGqqYhVcMPFFlEpd07fu/tNano3rwxPtA4ICK7s/fgmA+RY1PYvNqEWXNB3Tig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ARPelUuTT+YoaXxJYMYR/L6g+3B6EgsWgF+So1iOY75Ekdm74a2lxZL9c/Mn2/fp/voLuwneFzQjDLxzQzi2uDo9b+C85eIEcUIg+8CxNYhTqb7didm5XJ6ktYBFPLk1a+uDmDBgawNxwXPPLHci69gu34NnLDKf/AVJEbpiiBXJZJV97hyG7NdNUD3j5FBN7XfScsCBf/2QWM0KTZHyvaqVzLH1hVGAME4iHDShHAW4WAOpRsdn8Go/9sW/d8U2njah5axb+nyHn9gldFtS8Z/uW7EcHW0MpPbatAVXGjSr7210sODKQWx98TLHmkjxYcUaU21fxrYfLRaso5y5WQ==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@xxxxxxxx;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 15 Jul 2019 14:19:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVOvj6+Q8sMST8H0euZPd/xzIlP6bLsnl8gAAIFIA=
  • Thread-topic: [PATCH] x86/dom0-build: fix build with clang5

On 15.07.2019 15:49, Andrew Cooper wrote:
> On 15/07/2019 11:35, Jan Beulich wrote:
>> With non-empty CONFIG_DOM0_MEM clang5 produces
>>
>> dom0_build.c:344:24: error: use of logical '&&' with constant operand 
>> [-Werror,-Wconstant-logical-operand]
>>       if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
>>                          ^  ~~~~~~~~~~~~~~~~~~
>> dom0_build.c:344:24: note: use '&' for a bitwise operation
>>       if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
>>                          ^~
>>                          &
>> dom0_build.c:344:24: note: remove constant to silence this warning
>>       if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
>>                         ~^~~~~~~~~~~~~~~~~~~~~
>> 1 error generated.
>>
>> Obviously neither of the two suggestions are an option here. Oddly
>> enough swapping the operands of the && helps, while e.g. casting or
>> parenthesizing doesn't. Another workable variant looks to be the use of
>> !! on the constant.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> ---
>> I'm open to going the !! or yet some different route. No matter which
>> one we choose, I'm afraid it is going to remain guesswork what newer
>> (and future) versions of clang will choke on.
>>
>> --- a/xen/arch/x86/dom0_build.c
>> +++ b/xen/arch/x86/dom0_build.c
>> @@ -341,7 +341,7 @@ unsigned long __init dom0_compute_nr_pag
>>        unsigned long avail = 0, nr_pages, min_pages, max_pages;
>>        bool need_paging;
>>    
>> -    if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
>> +    if ( CONFIG_DOM0_MEM[0] && !dom0_mem_set )
>>            parse_dom0_mem(CONFIG_DOM0_MEM);
> 
> First and foremost, there is an identical construct on the ARM side,
> which wants an equivalent adjustment.

Oh, indeed. I should have remembered ...

> As to the change, I'm going to suggest what I suggested instead of this
> the first time around, which is strlen(CONFIG_DOM0_MEM) to make the
> logic easier to follow.

How does use of strlen() make anything easier? I think it is a pretty
common pattern to check the first character for nul if all one is
after is to know whether a string is empty.

Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.