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

Re: [PATCH 1/2] xen/cppcheck: add a way to exclude files from the scan


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Tue, 14 Feb 2023 10:02:13 +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=IWHrjZzJLOijSsGjJVv30G49BiGBRquzjp/IqgRSwck=; b=YY3eC8SWlaA2RH21JGzIGoGvsgIRFUuzwRJPSQaDUtsF1KR4PigE7EaSzGezjwN1Ooi/OIV1ZmAstVELIYajCV9CMhenDZF9UkWLcqUJ4yuYxLsn5TE945ZHleojOiFcAvg3bKLaSwg31UAU1A+tjGQjD8QDhZVGVfXQE2osGtW31ibkaFn44CgYgnPWax9MetPe0wNPsSrUL89I3TMKufyhNppPG8umjBOyyGL8ZYWX9KmqRo1WT76ZjZPO93S9sOnjtK5SXYA6GtpSGhFWyCORj4+d2yAumgOtiDt6E5MqxLQjWD02sRnBiSAA8JvlSqFfX8ounXVF2T9lbtChgw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OxQw1KU0CEQgEUhsMYmdsvzSihGT6qrcc5gCJP8EssbDRNYTvVGKODU1Whr7XCxEydBwrXOHx/ylEvG2ijFpzNXysGdKH+noMV46RZFM1JHJYSbowSVOujbHNpQtWUFoGYW7+ki48cw7VmLBS3ht/yT/VPYufVwQJVb99HnwV6cBv4dcHfxbiQuBOg4n1kzEAl67ukApBvQ3hT0ekTc6gMoxoOin1M13GCYLFDuHlFhOCPRGJEkl83QTzmbQ/lAuKUP1FCQH6XnyL8B6Dvo/MDKJ52klY1jOmOID3XOj77cQyzkkgrOFKceuNhCkmpdUaaRjSItsTxydRA/9hTvfqw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Wei Chen <Wei.Chen@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 14 Feb 2023 10:03:15 +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: AQHZQFJldh/RodYIGE6PF+KtzbPV1a7OMzSAgAAC6wA=
  • Thread-topic: [PATCH 1/2] xen/cppcheck: add a way to exclude files from the scan


> On 14 Feb 2023, at 09:51, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 14.02.2023 09:56, Luca Fancellu wrote:
>> Add a way to exclude files from the scan, in this way we can skip
>> some findings from the report on those files that Xen doesn't own.
>> 
>> To do that, introduce the exclude-list.json file under docs/misra,
>> this file will be populated with relative path to the files/folder
>> to be excluded.
>> Introduce a new module, exclusion_file_list.py, to deal with the
>> exclusion list file and use the new module in cppcheck_analysis.py
>> to take a list of excluded paths to update the suppression list of
>> cppcheck.
>> Modified --suppress flag for cppcheck tool to remove
>> unmatchedSuppression findings for those external file that are
>> listed but for example not built for the current architecture.
>> 
>> Add documentation for the file.
>> 
>> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
>> ---
>> docs/misra/exclude-list.json                  |  4 +
>> docs/misra/exclude-list.rst                   | 44 +++++++++++
>> xen/scripts/xen_analysis/cppcheck_analysis.py | 21 ++++-
>> .../xen_analysis/exclusion_file_list.py       | 79 +++++++++++++++++++
>> 4 files changed, 146 insertions(+), 2 deletions(-)
>> create mode 100644 docs/misra/exclude-list.json
>> create mode 100644 docs/misra/exclude-list.rst
>> create mode 100644 xen/scripts/xen_analysis/exclusion_file_list.py
> 
> As I think I have asked for before: Can new files please avoid underscores
> in their names, when dashes do quite fine? Or does Python have special
> restrictions?

From the python coding style:

Modules should have short, all-lowercase names. Underscores can be used in
the module name if it improves readability. Python packages should also have
short, all-lowercase names, although the use of underscores is discouraged.

In this case I think it improves readability

> 
>> --- a/xen/scripts/xen_analysis/cppcheck_analysis.py
>> +++ b/xen/scripts/xen_analysis/cppcheck_analysis.py
>> @@ -1,7 +1,8 @@
>> #!/usr/bin/env python3
>> 
>> import os, re, shutil
>> -from . import settings, utils, cppcheck_report_utils
>> +from . import settings, utils, cppcheck_report_utils, exclusion_file_list
>> +from .exclusion_file_list import ExclusionFileListError
>> 
>> class GetMakeVarsPhaseError(Exception):
>>     pass
>> @@ -50,6 +51,22 @@ def __generate_suppression_list(out_file):
>>             # header for cppcheck
>>             supplist_file.write("*:*generated/compiler-def.h\n")
>> 
>> +            try:
>> +                exclusion_file = \
>> +                    
>> "{}/docs/misra/exclude-list.json".format(settings.repo_dir)
>> +                exclusion_list = \
>> +                    
>> exclusion_file_list.load_exclusion_file_list(exclusion_file)
>> +            except ExclusionFileListError as e:
>> +                    raise CppcheckDepsPhaseError(
>> +                            "Issue with reading file {}: {}"
>> +                                .format(exclusion_file, e)
>> +                          )
> 
> My Python isn't very good, but isn't indentation one level too deep
> here?

Good catch, I’ll fix it

> 
> Jan



 


Rackspace

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