[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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 24 Mar 2022 13:14:10 +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=u+ZNNO57lwXp6OS5Qzumv2jLyCPJzdejkFnuBLLYtG4=; b=IMtVGTUzJUPbpJPDtg857f8LZqGpc2rKkOd4AcpX3i8MD0S7Mm3Hm/0nf9WJ8HTaJNmgNlPJGfnAzEH2mup4gFEaNEnylT/RolYSVIboJ0QFcGA4fnAyqyZq9iqiui5gByt6MMF6Z/CQNg3wxqVnf9IOL9eJtCYcvj+PPTJP4p+IDqVr2VHWrHQcVgwyvNqMHidGTsmH6IlRDfQc2m1fW+yNE5HxGJBn4QARgKom5HsWKBCRrVlV0YY88IgfKxgq4M3x3E0r2VYEt1Q4/FStvuCZV6p6STcaATW6TdLimyKaxAXrAZOREMTirSEUl58BThwNyIaC4cGuJ3JfIuwoKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DdcIvQ2Scut+KXrz2kEwz6xG1S3mqgcf+NFfh4LV6vh/iT1EX1yuGSnUp1qNB2zHeNtBJC2i+7HuXakTreh/uDM3ouOwfm5psNRqx9asLlmRqFCZWvq5iCrZFGCrAeDXZ6mDXyLBcnppKB2NlLfL4CvU3Ln8wxWVoJOZYErcklrSYX0iTK+04UEikIjfLuYP8vPgIQPNcvvrbGjP5e327GrkSPlWuLG9mMiP1GicgJVWGb6kg1uLqeDlsK086M//ZUQ1YvmaPFXILprbNuHlaiq99XXlmkoVCCtuqsfElSe/A3S++ZvD2zEbfgxLyMCv9eOdTQ6s3eH0cgC3gkG+XQ==
  • 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>, George Dunlap <George.Dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Michal Orzel <Michal.Orzel@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Thu, 24 Mar 2022 13:14:34 +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+NG7Po4Qnn9azOgP+AgAACOoA=
  • Thread-topic: [RFC PATCH] xen/build: Add cppcheck and cppcheck-html make rules

Hi Andrew,

> On 24 Mar 2022, at 14:06, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
> 
> On 24/03/2022 11:04, Bertrand Marquis wrote:
>> cppcheck can be used to check Xen code quality.
>> 
>> 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.
>> 
>> 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>
> 
> Does CPPCheck have configurable errors vs warnings?  Should we wire this
> into CI so we can fail builds which introduce errors that we've already
> managed to purge from the codebase?

No we cannot configure which findings are errors or warnings.
What we can (and probably will) do is create a list of cppcheck rules that we
want to check and pass that to cppcheck (can be done using a text file). Once
this is done and all findings are solved we should definitely add cppcheck to 
the
CI and fail builds when errors are introduced.

> 
> Also, please include Anthony on future patches, given the extent of
> makefile changes.

I will for sure.

Cheers
Bertrand




 


Rackspace

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