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

Re: [RFC PATCH] xen/build: Add cppcheck and cppcheck-html make rules


  • To: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 25 Mar 2022 15:30:45 +0100
  • 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RcMAAhdZCotWsPuQHx6W3jbutQvXH9hJ2Q2bCP+o778=; b=PaYziWJ1unFeJD8VU+QCO6tFRVl2dlpSes5rIqp/HLfpglys4icNJEeOJ/SPmhK1Tv5q/gHKJ8F7AdFEXf4zpDG6zC5UdhmypYhX2Gqc8HaaUwSX1V/OiUN6uCXU5FaLtuVTPQQrkjLtuqjDQySk9KNNwuB2WqreM80H6afe/mA65auaws9rrW/5RU67UBqU7yCq1rmY3tbN5fu7QpMBZTVLsme3tMf7SeT+9EB4wyhMbkvte5isI9KptAsJyn2x8IHXU+cZoUNY1vBlw/ky1/IuEK0qk4QeY5i52O1wvjGpS9npPGutX5bQ/4ZrRpgJrOA7eGH0E/zg6iHZr0xUtg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUJfI7EFRaDu33eAiv9awdvOYkeVGERjSw8xM8evP2aqovr0y3IB430BT6z0B8kT+gw0p/0zaYsdMiem7Mj/fLM/LzR/J+oZeO8KTwiXLiHTcHGq+4U4RJ35qdqCTAg9Lv0tBSuup0LOhZ5hxP3mUhwhVIelYDPEhsWCsa0d5gwtbShmx/V1Md6jucmuAT1qghaI2OgPQ52L7arUeRZNGv4jDNFmTUILfYn8g89pLDma78605ABOhrbZ0acKG2CUT4RmLSrIbLngPIgJkLdfBJga0ibdeqWaHrD6jPlCIOoFeMIGLh4/amk3sFFmJRn0WLF1eg5OgzN4iycwinVwrw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Michal Orzel <Michal.Orzel@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 25 Mar 2022 14:30:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25.03.2022 15:28, Bertrand Marquis wrote:
>> On 25 Mar 2022, at 15:10, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>> On 25.03.2022 13:57, Bertrand Marquis wrote:
>>>> On 25 Mar 2022, at 12:43, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>>> On 24.03.2022 12:04, Bertrand Marquis wrote:
>>>>> --- a/xen/include/xen/kconfig.h
>>>>> +++ b/xen/include/xen/kconfig.h
>>>>> @@ -8,6 +8,10 @@
>>>>> * these only work with boolean option.
>>>>> */
>>>>>
>>>>> +/* cppcheck is failing to parse the macro so use a dummy one */
>>>>> +#ifdef CPPCHECK
>>>>> +#define IS_ENABLED(option) option
>>>>> +#else
>>>>> /*
>>>>> * Getting something that works in C and CPP for an arg that may or may
>>>>> * not be defined is tricky.  Here, if we have "#define CONFIG_BOOGER 1"
>>>>> @@ -27,5 +31,6 @@
>>>>> * otherwise.
>>>>> */
>>>>> #define IS_ENABLED(option) config_enabled(option)
>>>>> +#endif
>>>>
>>>> What are the consequences of this workaround on the code actually
>>>> being checked? Does this perhaps lead to certain portions of code
>>>> being skipped while checking?
>>>
>>> Cppcheck is not optimising the code but looking at the syntax so the
>>> consequence here is that cppcheck is checking some code which might
>>> be optimised out by the compiler. This is not optimal but still it should
>>> analyse properly the code.
>>
>> Aren't you saying so merely because all uses of IS_ENABLED() in our
>> sources so far are in if()? It would seem to me that when used in #if
>> (as can be found in Linux, which hence means could be the case in our
>> tree as well sooner or later) sections of code might either be skipped
>> or syntax errors may result. Or wait - IS_ENABLED() does itself kind
>> of rely on the respective CONFIG_* to expand to a numeric value; when
>> expanding to a string, I guess the compiler would also warn about the
>> resulting construct when used in if() (and reject any uses with #if).
> 
> I am not quite sure I am following what you are saying (or asking).

I first tried to clarify what I'm concerned about, but then said that
apparently there is no reason to be concerned. I'm sorry if this didn't
come across quite clear enough. Bottom line - no request for any
change here.

Jan

> I say that most use cases are if (IS_ENABLED(x)) so from the syntax point
> of view it is ok to not do exactly as IS_ENABLED really does. And
> cppcheck is checking the code not the result.
> Now it would be better to do it right but the point of the patch is to enable
> cppcheck not make it perfect on the first shot.
> 
> Cheers
> Bertrand
> 
>>
>> Jan
>>
> 




 


Rackspace

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