[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:10:25 +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=yaNnS2n/i0Q3uNjcxUqxb/chRzneWFMAJAx8oPLdlq0=; b=TQqd17WmD5gSRkaUtBgbKynSv7gYuUp+JA8ZjQHSmDg2+IqS833Bu0ng/7QcEPOaFBu5SmNom+e0w7MHOgfeZZXV8I+0NxemmJvQY+HaQxaW4zJxtp+3WQSHLAU8v6F29Jlo4mdZirMsyMGNElOwvwCU9Mt1A8IynTIuPHZIyQGz95m3TVjgja6pjrE1ct/JEPRUu27/Sz10c4zP95zHUtkJQLLvAvvywomFEdT7c/w4Q/LU32p7zzhl+AHH0wcKFVPU3g7XkjYY1mMUf2UNKbLBMBZepcYM0o0x1Br5RNGLBbNvCNQ1fVS4acgYFcBcsSP6m/LGjY0NKtQAo0OaIA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTiZfKLdHqh4JJpXWOdbw5wvlwW5rejaLn0vfdNL74UHNrWD6LaWQyd67CETFcACD4ZvBP2AFE0GBMOiJWkaJS+tkmbGKrGfzYPdNTTMkW123yBhXPJ6cGCg4IOnNc/O5WlYvWd72auZwHZDab7ddBjYENR05JXSqtiDgJABGny5EWcgltyVP/NfCYa2XiLJO/83qVuqU6PnBLNdQCAcgXn6p2T3ZqaPpuOuCiB8YdQzZ3sdIdL7tP+1A7HnB6QP5J7Lppvx+D+W53YuWyChgsObwOrJmkGx4iQcDHjmR//FU3zQZOEMwyZlrcKQvBmADlLiQm1J95nVkqetFO9YuQ==
  • 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:10:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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).

Jan




 


Rackspace

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