All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Fancellu <luca.fancellu@arm.com>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>
Subject: [RFC PATCH v2 1/8] cppcheck: rework exclusion_file_list.py code
Date: Tue, 31 Oct 2023 13:22:57 +0000	[thread overview]
Message-ID: <20231031132304.2573924-2-luca.fancellu@arm.com> (raw)
In-Reply-To: <20231031132304.2573924-1-luca.fancellu@arm.com>

Rework the exclusion_file_list.py code to have the function
load_exclusion_file_list() detached from the xen-analysis.py tool,
in a way so that other modules can use the function.
The xen-analysis tool and in particular its module cppcheck_analysis.py
will use a new function cppcheck_exclusion_file_list().

No functional changes are intended.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/scripts/xen_analysis/cppcheck_analysis.py |  6 ++--
 .../xen_analysis/exclusion_file_list.py       | 31 ++++++++++---------
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xen_analysis/cppcheck_analysis.py
index 8dc45e653b79..e54848aa5339 100644
--- a/xen/scripts/xen_analysis/cppcheck_analysis.py
+++ b/xen/scripts/xen_analysis/cppcheck_analysis.py
@@ -2,7 +2,8 @@
 
 import os, re, shutil
 from . import settings, utils, cppcheck_report_utils, exclusion_file_list
-from .exclusion_file_list import ExclusionFileListError
+from .exclusion_file_list import (ExclusionFileListError,
+                                  cppcheck_exclusion_file_list)
 
 class GetMakeVarsPhaseError(Exception):
     pass
@@ -54,8 +55,7 @@ def __generate_suppression_list(out_file):
             try:
                 exclusion_file = \
                     "{}/docs/misra/exclude-list.json".format(settings.repo_dir)
-                exclusion_list = \
-                    exclusion_file_list.load_exclusion_file_list(exclusion_file)
+                exclusion_list = cppcheck_exclusion_file_list(exclusion_file)
             except ExclusionFileListError as e:
                 raise CppcheckDepsPhaseError(
                     "Issue with reading file {}: {}".format(exclusion_file, e)
diff --git a/xen/scripts/xen_analysis/exclusion_file_list.py b/xen/scripts/xen_analysis/exclusion_file_list.py
index 871e480586bb..79ebd34f55ec 100644
--- a/xen/scripts/xen_analysis/exclusion_file_list.py
+++ b/xen/scripts/xen_analysis/exclusion_file_list.py
@@ -7,16 +7,24 @@ class ExclusionFileListError(Exception):
     pass
 
 
-def __cppcheck_path_exclude_syntax(path):
-    # Prepending * to the relative path to match every path where the Xen
-    # codebase could be
-    path = "*" + path
+def cppcheck_exclusion_file_list(input_file):
+    ret = []
+    excl_list = load_exclusion_file_list(input_file)
+
+    for entry in excl_list:
+        # Prepending * to the relative path to match every path where the Xen
+        # codebase could be
+        ret.append("*" + entry[0])
 
-    return path
+    return ret
 
 
-# Reads the exclusion file list and returns a list of relative path to be
-# excluded.
+# Reads the exclusion file list and returns an array containing a set where the
+# first entry is what was listed in the exclusion list file, and the second
+# entry is the absolute path of the first entry.
+# If the first entry contained a wildcard '*', the second entry will have an
+# array of the solved absolute path for that entry.
+# Returns [('path',[path,path,...]), ('path',[path,path,...]), ...]
 def load_exclusion_file_list(input_file):
     ret = []
     try:
@@ -58,13 +66,6 @@ def load_exclusion_file_list(input_file):
                     .format(path, filepath_object)
                 )
 
-        if settings.analysis_tool == "cppcheck":
-            path = __cppcheck_path_exclude_syntax(path)
-        else:
-            raise ExclusionFileListError(
-                "Unimplemented for {}!".format(settings.analysis_tool)
-            )
-
-        ret.append(path)
+        ret.append((path, check_path))
 
     return ret
-- 
2.34.1



  reply	other threads:[~2023-10-31 13:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 13:22 [RFC PATCH v2 0/8] clang-format for Xen Luca Fancellu
2023-10-31 13:22 ` Luca Fancellu [this message]
2023-10-31 13:22 ` [RFC PATCH v2 2/8] exclude-list: generalise exclude-list Luca Fancellu
2023-10-31 13:22 ` [RFC PATCH v2 3/8] [WIP]xen/scripts: add codestyle.py script Luca Fancellu
2023-10-31 13:23 ` [RFC PATCH v2 4/8] exclude-list: add entries to the excluded list for codestyle Luca Fancellu
2023-10-31 13:23 ` [RFC PATCH v2 5/8] [WIP]codestyle.py: Protect generic piece of code Luca Fancellu
2023-10-31 13:23 ` [RFC PATCH v2 6/8] [WIP]x86/exclude-list: protect mm_type_tbl in mtrr from being formatted Luca Fancellu
2023-10-31 13:23 ` [RFC PATCH v2 7/8] xen: Add clang-format configuration Luca Fancellu
2023-11-02  9:10   ` Jan Beulich
2023-11-02 11:41     ` Luca Fancellu
2023-11-02 11:53       ` Jan Beulich
2023-11-02 16:13         ` Luca Fancellu
2023-10-31 13:23 ` [RFC PATCH v2 8/8] feedback from the community Luca Fancellu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231031132304.2573924-2-luca.fancellu@arm.com \
    --to=luca.fancellu@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.