Skip to contentSkip to conversation

xen/misra: create exclusion file list

PATCH Superseded Luca Fancellu 2 participants 8 messages Mar 1, 2023 – Mar 2, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover xen/misra: create exclusion file list

This serie is introducing an exclusion list for the misra analysis, at the moment only cppcheck can benefit from it because it's the tool where we control every step and configuration.

Exclude a file from the analysis is the last step we should do, but sometime it is unavoidable because we can't do direct changes to it to fix/deviate from findings.
So we declare the file(s) here and we leave the burden of the misra compliance to the final user.

Luca Fancellu (2):
xen/cppcheck: add a way to exclude files from the scan xen/misra: add entries to exclude-list.json

 docs/misra/exclude-list.json                  | 201 ++++++++++++++++++
 docs/misra/exclude-list.rst                   |  44 ++++
 xen/scripts/xen_analysis/cppcheck_analysis.py |  20 +-
 .../xen_analysis/exclusion_file_list.py       |  79 +++++++
 4 files changed, 342 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
Signature · 1 line
2.34.1
#1 lore raw

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

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.

---
Changes from v1:
- Indentation fixed (Jan)
---

---
 docs/misra/exclude-list.json                  |  4 +
 docs/misra/exclude-list.rst                   | 44 +++++++++++
 xen/scripts/xen_analysis/cppcheck_analysis.py | 20 ++++-
 .../xen_analysis/exclusion_file_list.py       | 79 +++++++++++++++++++
 4 files changed, 145 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
docs/misra/exclude-list.json new file +4 -0
new file mode 100644
index 000000000000..1fb0ac67747b
@@ -0,0 +1,4 @@
+{
+    "version": "1.0",
+    "content": []
+}
docs/misra/exclude-list.rst new file +44 -0

44 lines not on this page · raw message

xen/scripts/xen_analysis/cppcheck_analysis.py +18 -2
index cc1f403d315e..e385e2c8f54a 100644
@@ -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,21 @@ 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)
+                )
+
+            # Append excluded files to the suppression list, using * as error id
+            # to suppress every findings on that file
+            for path in exclusion_list:
+                supplist_file.write("*:{}\n".format(path))
+
             for entry in headers:
                 filename = entry["file"]
                 try:
@@ -128,7 +144,7 @@ def generate_cppcheck_deps():
  --relative-paths={}
  --inline-suppr
  --suppressions-list={}/suppression-list.txt
- --suppress='unmatchedSuppression:*generated/compiler-def.h'
+ --suppress='unmatchedSuppression:*'
  --include={}/include/xen/config.h
  -DCPPCHECK
 """.format(settings.outdir, CPPCHECK_BUILD_DIR, settings.xen_dir,
xen/scripts/xen_analysis/exclusion_file_list.py new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

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

Quoted 47 lines · Luca Fancellu

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.

---
Changes from v1:
- Indentation fixed (Jan)
---

---
 docs/misra/exclude-list.json                  |  4 +
 docs/misra/exclude-list.rst                   | 44 +++++++++++
 xen/scripts/xen_analysis/cppcheck_analysis.py | 20 ++++-
 .../xen_analysis/exclusion_file_list.py       | 79 +++++++++++++++++++
 4 files changed, 145 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
docs/misra/exclude-list.json new file +4 -0
new file mode 100644
index 000000000000..1fb0ac67747b
@@ -0,0 +1,4 @@
+{
+    "version": "1.0",
+    "content": []
+}
docs/misra/exclude-list.rst new file +0 -0
new file mode 100644
index 000000000000..969539c46beb

docs/misra/exclude-list.rst line 10

Quoted 10 lines
docs/misra/exclude-list.rst new file +10 -0
@@ -0,0 +1,44 @@
+.. SPDX-License-Identifier: CC-BY-4.0
+
+Exclude file list for xen-analysis script
+=========================================
+
+The code analysis is performed on the Xen codebase for both MISRA checkers and
+static analysis checkers, there are some files however that needs to be removed
+from the findings report because they are not owned by Xen and they must be kept
+in sync with their origin (completely or even partially), hence we can't easily
+fix findings or deviate from them.

I would stay more generic and say something like:

The code analysis is performed on the Xen codebase for both MISRA checkers and static analysis checkers, there are some files however that needs to be removed from the findings report for various reasons (e.g. they are imported from external sources, they generate too many false positive results, etc.).

But what you wrote is also OK.

Quoted 90 lines
docs/misra/exclude-list.rst new file +33 -0
+For this reason the file docs/misra/exclude-list.json is used to exclude every
+entry listed in that file from the final report.
+Currently only the cppcheck analysis will use this file.
+
+Here is an example of the exclude-list.json file::
+
+|{
+|    "version": "1.0",
+|    "content": [
+|        {
+|            "rel_path": "relative/path/from/xen/file",
+|            "comment": "This file is originated from ..."
+|        },
+|        {
+|            "rel_path": "relative/path/from/xen/folder/*",
+|            "comment": "This folder is a library"
+|        },
+|        {
+|            "rel_path": "relative/path/from/xen/mem*.c",
+|            "comment": "memcpy.c, memory.c and memcmp.c are from the outside"
+|        }
+|    ]
+|}
+
+Here is an explanation of the fields inside an object of the "content" array:
+ - rel_path: it is the relative path from the Xen folder to the file/folder that
+   needs to be excluded from the analysis report, it can contain a wildcard to
+   match more than one file/folder at the time. This field is mandatory.
+ - comment: an optional comment to explain why the file is removed from the
+   analysis.
+
+To ease the review and the modifications of the entries, they shall be listed in
+alphabetical order referring to the rel_path field.
xen/scripts/xen_analysis/cppcheck_analysis.py +18 -2
index cc1f403d315e..e385e2c8f54a 100644
@@ -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,21 @@ 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)
+                )
+
+            # Append excluded files to the suppression list, using * as error id
+            # to suppress every findings on that file
+            for path in exclusion_list:
+                supplist_file.write("*:{}\n".format(path))
+
             for entry in headers:
                 filename = entry["file"]
                 try:
@@ -128,7 +144,7 @@ def generate_cppcheck_deps():
  --relative-paths={}
  --inline-suppr
  --suppressions-list={}/suppression-list.txt
- --suppress='unmatchedSuppression:*generated/compiler-def.h'
+ --suppress='unmatchedSuppression:*'
  --include={}/include/xen/config.h
  -DCPPCHECK
 """.format(settings.outdir, CPPCHECK_BUILD_DIR, settings.xen_dir,
xen/scripts/xen_analysis/exclusion_file_list.py new file +6 -0
new file mode 100644
index 000000000000..4a47a90f5944
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+
+import os, glob, json
+from . import settings
+
+class ExclusionFileListError(Exception):

xen/scripts/xen_analysis/exclusion_file_list.py line 16

Quoted 10 lines
xen/scripts/xen_analysis/exclusion_file_list.py new file +10 -0
+    pass
+
+
+def __cppcheck_path_exclude_syntax(path):
+    # Prepending * to the relative path to match every path where the Xen
+    # codebase could be
+    path = "*" + path
+
+    # Check if the path is to a folder without the wildcard at the end
+    if not (path.endswith(".c") or path.endswith(".h") or path.endswith("*")):

Isn't there a python call to check that it is actually a folder? I think that would be more resilient because otherwise if someone passes a .S or .cpp file it would be detected as directory.

Quoted 66 lines
xen/scripts/xen_analysis/exclusion_file_list.py new file +63 -0
+        # The path is to a folder, if it doesn't have the final /, add it
+        if not path.endswith("/"):
+            path = path + "/"
+        # Since the path is a folder, add a wildcard to the end so that
+        # cppcheck will remove every issue related with this path
+        path = path + "*"
+
+    return path
+
+
+# Reads the exclusion file list and returns a list of relative path to be
+# excluded.
+def load_exclusion_file_list(input_file):
+    ret = []
+    try:
+        with open(input_file, "rt") as handle:
+            content = json.load(handle)
+            entries = content['content']
+    except json.JSONDecodeError as e:
+        raise ExclusionFileListError(
+                "JSON decoding error in file {}: {}".format(input_file, e)
+        )
+    except KeyError:
+        raise ExclusionFileListError(
+            "Malformed JSON file: content field not found!"
+        )
+    except Exception as e:
+        raise ExclusionFileListError(
+                "Can't open file {}: {}".format(input_file, e)
+        )
+
+    for entry in entries:
+        try:
+            path = entry['rel_path']
+        except KeyError:
+            raise ExclusionFileListError(
+                "Malformed JSON entry: rel_path field not found!"
+            )
+        abs_path = settings.xen_dir + "/" + path
+        check_path = [abs_path]
+
+        # If the path contains wildcards, solve them
+        if '*' in abs_path:
+            check_path = glob.glob(abs_path)
+
+        # Check that the path exists
+        for filepath_object in check_path:
+            if not os.path.exists(filepath_object):
+                raise ExclusionFileListError(
+                    "Malformed path: {} refers to {} that does not exists"
+                    .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)
+
+    return ret
Signature · 1 line
2.34.1
#3 lore raw

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

Quoted 12 lines

Review

Quoted 9 lines
(quoted diff) +8 -0
+Exclude file list for xen-analysis script
+=========================================
+
+The code analysis is performed on the Xen codebase for both MISRA checkers and
+static analysis checkers, there are some files however that needs to be removed
+from the findings report because they are not owned by Xen and they must be kept
+in sync with their origin (completely or even partially), hence we can't easily
+fix findings or deviate from them.

I would stay more generic and say something like:

Quoted 7 lines

The code analysis is performed on the Xen codebase for both MISRA checkers and static analysis checkers, there are some files however that needs to be removed from the findings report for various reasons (e.g. they are imported from external sources, they generate too many false positive results, etc.).

But what you wrote is also OK.

I’m ok with that too, I can update with your wordings

Quoted 15 lines
Quoted 15 lines

+++ b/xen/scripts/xen_analysis/exclusion_file_list.py

(quoted diff) +12 -0
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+
+import os, glob, json
+from . import settings
+
+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
Quoted 18 lines

Review line 16

Quoted 4 lines
(quoted diff) +4 -0
+    path = "*" + path
+
+    # Check if the path is to a folder without the wildcard at the end
+    if not (path.endswith(".c") or path.endswith(".h") or path.endswith("*")):

Isn't there a python call to check that it is actually a folder? I think that would be more resilient because otherwise if someone passes a .S or .cpp file it would be detected as directory.

Quoted 8 lines
(quoted diff) +8 -0
+        # The path is to a folder, if it doesn't have the final /, add it
+        if not path.endswith("/"):
+            path = path + "/"
+        # Since the path is a folder, add a wildcard to the end so that
+        # cppcheck will remove every issue related with this path
+        path = path + "*"
+
+    return path

Yes you are very right, here I wanted to accept the relative path to a folder with or without the ending '/*’, but it carries on much more complexity because here the relative path can contain wildcards in it, so we can’t use os.path.isdir() which would fail.

At cost of being more strict on how folders shall be declared, I think it’s better to enforce the ‘/*’ at the end of a path that is excluding a folder.

We have a previous check using glob() to ensure path with wildcards are real path so we are safe that the passed relative path are OK.

Dropping the requirement of passing folder paths with or without the ‘/*’ simplifies the code and this would be the final result:

docs/misra/exclude-list.rst +7 -5
index 969539c46beb..c97431a86120 100644
@@ -3,11 +3,11 @@
 Exclude file list for xen-analysis script
 =========================================
 
-The code analysis is performed on the Xen codebase for both MISRA checkers and
-static analysis checkers, there are some files however that needs to be removed
-from the findings report because they are not owned by Xen and they must be kept
-in sync with their origin (completely or even partially), hence we can't easily
-fix findings or deviate from them.
+The code analysis is performed on the Xen codebase for both MISRA
+checkers and static analysis checkers, there are some files however that
+needs to be removed from the findings report for various reasons (e.g.
+they are imported from external sources, they generate too many false
+positive results, etc.).
 
 For this reason the file docs/misra/exclude-list.json is used to exclude every
 entry listed in that file from the final report.
@@ -42,3 +42,5 @@ Here is an explanation of the fields inside an object of the "content" array:
 
 To ease the review and the modifications of the entries, they shall be listed in
 alphabetical order referring to the rel_path field.
+Excluded folder paths shall end with '/*' in order to match everything on that
+folder.
xen/scripts/xen_analysis/exclusion_file_list.py +0 -9
index 4a47a90f5944..871e480586bb 100644
@@ -12,15 +12,6 @@ def __cppcheck_path_exclude_syntax(path):
     # codebase could be
     path = "*" + path
 
-    # Check if the path is to a folder without the wildcard at the end
-    if not (path.endswith(".c") or path.endswith(".h") or path.endswith("*")):
-        # The path is to a folder, if it doesn't have the final /, add it
-        if not path.endswith("/"):
-            path = path + "/"
-        # Since the path is a folder, add a wildcard to the end so that
-        # cppcheck will remove every issue related with this path
-        path = path + "*"
-
     return path
 
 

I’ve included also your wording and I’ve specified in the docs how to exclude a folder.

Do you think it’s ok to proceed in this way?

Cheers,
Luca

#4 lore raw

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

Quoted 118 lines · Luca Fancellu
Quoted 11 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+Exclude file list for xen-analysis script
+=========================================
+
+The code analysis is performed on the Xen codebase for both MISRA checkers and
+static analysis checkers, there are some files however that needs to be removed
+from the findings report because they are not owned by Xen and they must be kept
+in sync with their origin (completely or even partially), hence we can't easily
+fix findings or deviate from them.

I would stay more generic and say something like:

Quoted 7 lines

The code analysis is performed on the Xen codebase for both MISRA checkers and static analysis checkers, there are some files however that needs to be removed from the findings report for various reasons (e.g. they are imported from external sources, they generate too many false positive results, etc.).

But what you wrote is also OK.

I’m ok with that too, I can update with your wordings

Quoted 15 lines
Quoted 15 lines

+++ b/xen/scripts/xen_analysis/exclusion_file_list.py

(quoted diff) +12 -0
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+
+import os, glob, json
+from . import settings
+
+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
Quoted 18 lines

Review line 16

Quoted 4 lines
(quoted diff) +4 -0
+    path = "*" + path
+
+    # Check if the path is to a folder without the wildcard at the end
+    if not (path.endswith(".c") or path.endswith(".h") or path.endswith("*")):

Isn't there a python call to check that it is actually a folder? I think that would be more resilient because otherwise if someone passes a .S or .cpp file it would be detected as directory.

Quoted 8 lines
(quoted diff) +8 -0
+        # The path is to a folder, if it doesn't have the final /, add it
+        if not path.endswith("/"):
+            path = path + "/"
+        # Since the path is a folder, add a wildcard to the end so that
+        # cppcheck will remove every issue related with this path
+        path = path + "*"
+
+    return path

Yes you are very right, here I wanted to accept the relative path to a folder with or without the ending '/*’, but it carries on much more complexity because here the relative path can contain wildcards in it, so we can’t use os.path.isdir() which would fail.

At cost of being more strict on how folders shall be declared, I think it’s better to enforce the ‘/*’ at the end of a path that is excluding a folder.

We have a previous check using glob() to ensure path with wildcards are real path so we are safe that the passed relative path are OK.

Dropping the requirement of passing folder paths with or without the ‘/*’ simplifies the code and this would be the final result:

docs/misra/exclude-list.rst +7 -5
index 969539c46beb..c97431a86120 100644
@@ -3,11 +3,11 @@
 Exclude file list for xen-analysis script
 =========================================
 
-The code analysis is performed on the Xen codebase for both MISRA checkers and
-static analysis checkers, there are some files however that needs to be removed
-from the findings report because they are not owned by Xen and they must be kept
-in sync with their origin (completely or even partially), hence we can't easily
-fix findings or deviate from them.
+The code analysis is performed on the Xen codebase for both MISRA
+checkers and static analysis checkers, there are some files however that
+needs to be removed from the findings report for various reasons (e.g.
+they are imported from external sources, they generate too many false
+positive results, etc.).
 
 For this reason the file docs/misra/exclude-list.json is used to exclude every
 entry listed in that file from the final report.
@@ -42,3 +42,5 @@ Here is an explanation of the fields inside an object of the "content" array:
 
 To ease the review and the modifications of the entries, they shall be listed in
 alphabetical order referring to the rel_path field.
+Excluded folder paths shall end with '/*' in order to match everything on that
+folder.
xen/scripts/xen_analysis/exclusion_file_list.py +0 -9
index 4a47a90f5944..871e480586bb 100644
@@ -12,15 +12,6 @@ def __cppcheck_path_exclude_syntax(path):
     # codebase could be
     path = "*" + path
 
-    # Check if the path is to a folder without the wildcard at the end
-    if not (path.endswith(".c") or path.endswith(".h") or path.endswith("*")):
-        # The path is to a folder, if it doesn't have the final /, add it
-        if not path.endswith("/"):
-            path = path + "/"
-        # Since the path is a folder, add a wildcard to the end so that
-        # cppcheck will remove every issue related with this path
-        path = path + "*"
-
     return path
 
 

I’ve included also your wording and I’ve specified in the docs how to exclude a folder.

Quoted 1 line

Do you think it’s ok to proceed in this way?

Yes I think that's fine. I like that the python script becomes simpler

#5 lore raw

PATCH v2 2/2 xen/misra: add entries to exclude-list.json

In reply to Luca Fancellu

Add entries to the exclude-list.json for those files that need to be excluded from the analysis scan.

---
This list is originated from Michal's work here:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/#25123099
and changed to adapt to this task.
Changes from v1:
- updated list with new files from Stefano
- add comment field for every entry (Jan)
---

---
 docs/misra/exclude-list.json | 199 ++++++++++++++++++++++++++++++++++-
 1 file changed, 198 insertions(+), 1 deletion(-)
docs/misra/exclude-list.json +198 -1
index 1fb0ac67747b..ca1e2dd678ff 100644
@@ -1,4 +1,201 @@
 {
     "version": "1.0",
-    "content": []
+    "content": [
+        {
+            "rel_path": "arch/arm/arm64/cpufeature.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/arm/arm64/insn.c",
+            "comment": "Imported on Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/arm/arm64/lib/find_next_bit.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/boot.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/cpu_idle.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/cpufreq/cpufreq.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/cpuidle_menu.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/lib.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/amd.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/centaur.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/common.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/hygon.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/intel.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/intel_cacheinfo.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/mcheck/non-fatal.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/mtrr/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/mwait-idle.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/delay.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/dmi_scan.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/mpparse.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/srat.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/time.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/x86_64/mmconf-fam10h.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/bitmap.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/bunzip2.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/earlycpio.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/inflate.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/libfdt/*",
+            "comment": "External library"
+        },
+        {
+            "rel_path": "common/livepatch_elf.c",
+            "comment": "Not in scope initially as it generates many violations and it is not enabled in safety configurations"
+        },
+        {
+            "rel_path": "common/lzo.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/lz4/decompress.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/radix-tree.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/ubsan/ubsan.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/un*.c",
+            "comment": "unlz4.c implementation by Yann Collet, the others un* are from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/xz/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/zstd/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "crypto/*",
+            "comment": "Origin is external and documented in crypto/README.source"
+        },
+        {
+            "rel_path": "drivers/acpi/apei/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/hwregs.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/numa.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/osl.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/tables.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/tables/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/utilities/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/video/font_*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "lib/list-sort.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "lib/rbtree.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "lib/xxhash*.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "xsm/flask/*",
+            "comment": "Not in scope initially as it generates many violations and it is not enabled in safety configurations"
+        }
+    ]
 }
Signature · 1 line
2.34.1
Reviewed-by on v2 2/2
#6 lore raw

Re: [PATCH v2 2/2] xen/misra: add entries to exclude-list.json

Quoted 5 lines · Luca Fancellu

Add entries to the exclude-list.json for those files that need to be excluded from the analysis scan.

I checked the results both x86 and arm and they look much more reasonable (with the exception of the way too many unusedStructMember reports on x86).

Quoted 222 lines

---
This list is originated from Michal's work here:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/#25123099
and changed to adapt to this task.
Changes from v1:
- updated list with new files from Stefano
- add comment field for every entry (Jan)
---

---
 docs/misra/exclude-list.json | 199 ++++++++++++++++++++++++++++++++++-
 1 file changed, 198 insertions(+), 1 deletion(-)
docs/misra/exclude-list.json +198 -1
index 1fb0ac67747b..ca1e2dd678ff 100644
@@ -1,4 +1,201 @@
 {
     "version": "1.0",
-    "content": []
+    "content": [
+        {
+            "rel_path": "arch/arm/arm64/cpufeature.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/arm/arm64/insn.c",
+            "comment": "Imported on Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/arm/arm64/lib/find_next_bit.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/boot.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/cpu_idle.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/cpufreq/cpufreq.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/cpuidle_menu.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/acpi/lib.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/amd.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/centaur.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/common.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/hygon.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/intel.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/intel_cacheinfo.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/mcheck/non-fatal.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/mtrr/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/cpu/mwait-idle.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/delay.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/dmi_scan.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/mpparse.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/srat.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/time.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "arch/x86/x86_64/mmconf-fam10h.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/bitmap.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/bunzip2.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/earlycpio.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/inflate.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/libfdt/*",
+            "comment": "External library"
+        },
+        {
+            "rel_path": "common/livepatch_elf.c",
+            "comment": "Not in scope initially as it generates many violations and it is not enabled in safety configurations"
+        },
+        {
+            "rel_path": "common/lzo.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/lz4/decompress.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/radix-tree.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/ubsan/ubsan.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/un*.c",
+            "comment": "unlz4.c implementation by Yann Collet, the others un* are from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/xz/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "common/zstd/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "crypto/*",
+            "comment": "Origin is external and documented in crypto/README.source"
+        },
+        {
+            "rel_path": "drivers/acpi/apei/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/hwregs.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/numa.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/osl.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/tables.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/tables/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/acpi/utilities/*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "drivers/video/font_*",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "lib/list-sort.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "lib/rbtree.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "lib/xxhash*.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
+        {
+            "rel_path": "xsm/flask/*",
+            "comment": "Not in scope initially as it generates many violations and it is not enabled in safety configurations"
+        }
+    ]
 }
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v2 2/2] xen/misra: add entries to exclude-list.json

Quoted 8 lines · Stefano Stabellini
Quoted 3 lines · Luca Fancellu

Add entries to the exclude-list.json for those files that need to be excluded from the analysis scan.

Quoted 7 lines
Quoted 2 lines

I checked the results both x86 and arm and they look much more reasonable (with the exception of the way too many unusedStructMember reports on x86).

Hi Stefano,

yes I will send a patch to suppress unusedStructMember globally