[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: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 24 Mar 2022 12:51:52 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=3XJwMMejm9GXSvgCe1exxwxvD/4wDjN8iPVcdEoB9SM=; b=CEgdWIbYfAWFCzHm/kzD1diXMVKE8ZOuHkunwf6bVRfBcSoITkZEnZfaZnLxt1Zk8v9bmRAIFPPYvI9FEpsOapHIfZEsG4tdPmcacgaTpDJNVZRAiWI/jHGXPUqmsYNxsUydEcXZ3aF2j3zwVdg5t//pJgvxXSXEscFldCWG2mjQpjvukpHRL9tW7/3eZhmaR0vJzroipxI3KnrwDchFYbFyOOiFZEvD4o4rSn/vti1jlzPuz2xzPcKqmHnQqPEUBQYaXu5mMcl4FnhSsWYj9M0Wm0V4hopmq8FOekaegPqXOqrbmiIGDcSqt7xILUHCJ+Kevhf1/wLyqJN7REC1Fg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kWNKrMWl7M6N5MuZzaLjXJwlGAHJq2t/kqk6Qec7zwIg6Hr3U204EvGMJiNFzP/Yx+u3m2ZyyGzoMzWJQBQrkJoD7MYppf32KCAQKTVUcJJdvyeXNY29AFRYnqmTl1AoMtVpHYc5A361OQ5sSnpMfAcM3IIfjNS5+5QrJmMll0riKiftdJpYKYcmHHFsBmbvZLeD+ZL/zTmswTKEVLXNNuVezvCFy9pu+tTWgAITD/Z56vmjlgf5M0ljcQw86jAyv9bFvAeeO8JKE9m5ddfTPY3TSbf7Mlv59iG0ve9klwU5QiDck83v6svUwO2xChDt6alTHx+gT44AVhZTP6o3RQ==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Michal Orzel <Michal.Orzel@xxxxxxx>
  • Delivery-date: Thu, 24 Mar 2022 12:54:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYP279DnP7J8Edsk+NG7Po4Qnn9azObqSAgAAOWoA=
  • Thread-topic: [RFC PATCH] xen/build: Add cppcheck and cppcheck-html make rules

Hi Julien,

> On 24 Mar 2022, at 13:00, Julien Grall <julien@xxxxxxx> wrote:
> 
> Hi Bertrand,
> 
> On 24/03/2022 11:04, Bertrand Marquis wrote:
>> cppcheck can be used to check Xen code quality.
> 
> Is there anything we should be concerned of in the initial report?

Nothing major no.
Michal will soon push a serie with a first set of fixes, mostly related to 
unused variables.

> 
>> To create a report do "make cppcheck" on a built tree adding any options
>> you added during the process you used to build xen (like CROSS_COMPILE
>> or XEN_TARGET_ARCH). This will generate an xml report xen-cppcheck.xml.
>> To create a html report do "make cppcheck-html" in the same way and a
>> full report to be seen in a browser will be generated in
>> cppcheck-htmlreport/index.html.
>> For better results it is recommended to build your own cppcheck from the
>> latest sources that you can find at [1].
>> Development and result analysis has been done with cppcheck 2.7.
> 
> We want to write down the minimum version of cppcheck we are going to 
> support. My suggestion would be to use the version you picked for your 
> development.

Agree, 2.7 (current stable) should be the one as we had some unstable 
behaviours with other versions.
Should I put that in the main readme ?

> 
>> The Makefile rule is searching for all C files which have been compiled
>> (ie which have a generated .o file) and is running cppcheck on all of
>> them using the current configuration of xen so only the code actually
>> compiled is checked.
>> A new tool is introduced to merge all cppcheck reports into one global
>> report including all findings and removing duplicates.
>> Some extra variables can be used to customize the report:
>> - CPPCHECK can be used to give the full path to the cppcheck binary to
>> use (default is to use the one from the standard path).
>> - CPPCHECK_HTMLREPORT can be used to give the full path to
>> cppcheck-htmlreport (default is to use the one from the standard path).
>> This has been tested on several arm configurations (x86 should work but
>> has not been tested).
>> [1] https://cppcheck.sourceforge.io/
>> Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
>> ---
>>  .gitignore                           |  3 ++
>>  xen/Makefile                         | 75 +++++++++++++++++++++++++++-
>>  xen/arch/arm/include/asm/processor.h |  4 +-
>>  xen/include/xen/config.h             |  4 ++
>>  xen/include/xen/kconfig.h            |  5 ++
>>  xen/tools/merge_cppcheck_reports.py  | 73 +++++++++++++++++++++++++++
> 
> In the long term, I think it would be useful if we generate the report 
> regularly. We might be able to hook the script that generate 
> https://xenbits.xen.org/docs/.

Agree

> 
>> diff --git a/xen/arch/arm/include/asm/processor.h 
>> b/xen/arch/arm/include/asm/processor.h
>> index 852b5f3c24..0b4ba73760 100644
>> --- a/xen/arch/arm/include/asm/processor.h
>> +++ b/xen/arch/arm/include/asm/processor.h
>> @@ -219,9 +219,11 @@
>>                           SCTLR_Axx_ELx_A    | SCTLR_Axx_ELx_C   |\
>>                           SCTLR_Axx_ELx_WXN  | SCTLR_Axx_ELx_EE)
>>  -#if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffffffffffffUL
>> +#ifndef CPPCHECK
>> +#if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffffffffffffULL
>>  #error "Inconsistent SCTLR_EL2 set/clear bits"
>>  #endif
>> +#endif
> 
> Why is it necessary?

The ULL was an attempt to fix but did not work. I will remove that in the next 
version.
Here cppcheck preprocessor is wrongly generating the error for a reason that I 
could not understand, hence the ifdef.

Cheers
Bertrand

> 
> Cheers,
> 
> -- 
> Julien Grall




 


Rackspace

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