2022-10-06 03:43:18

by Guru Das Srinagesh

[permalink] [raw]
Subject: [PATCH 1/2] scripts/clang-tools: Create array of checks to exclude

Create array of clang-analyzer checks to exclude for ease of adding
more. This is per the suggestion in an earlier discussion [1].

[1] https://lore.kernel.org/lkml/CAKwvOdnbMs-pLRfo4O-MHOF=9=kAvDuktkeeeX7bkmnLi8LWnw@mail.gmail.com/

Signed-off-by: Guru Das Srinagesh <[email protected]>
---
scripts/clang-tools/run-clang-tools.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py
index bb78c9b..a72c4c7 100755
--- a/scripts/clang-tools/run-clang-tools.py
+++ b/scripts/clang-tools/run-clang-tools.py
@@ -50,7 +50,12 @@ def run_analysis(entry):
checks += "linuxkernel-*"
else:
checks += "clang-analyzer-*"
- checks += ",-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
+
+ # List of checks to be excluded
+ exclude = []
+ exclude.append("-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling")
+
+ checks += ''.join(["," + e for e in exclude])
p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
--
2.7.4


2022-10-10 18:04:58

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH 1/2] scripts/clang-tools: Create array of checks to exclude

On Wed, Oct 5, 2022 at 8:24 PM Guru Das Srinagesh
<[email protected]> wrote:
>
> Create array of clang-analyzer checks to exclude for ease of adding
> more. This is per the suggestion in an earlier discussion [1].
>
> [1] https://lore.kernel.org/lkml/CAKwvOdnbMs-pLRfo4O-MHOF=9=kAvDuktkeeeX7bkmnLi8LWnw@mail.gmail.com/
>
> Signed-off-by: Guru Das Srinagesh <[email protected]>
> ---
> scripts/clang-tools/run-clang-tools.py | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py
> index bb78c9b..a72c4c7 100755
> --- a/scripts/clang-tools/run-clang-tools.py
> +++ b/scripts/clang-tools/run-clang-tools.py
> @@ -50,7 +50,12 @@ def run_analysis(entry):
> checks += "linuxkernel-*"
> else:
> checks += "clang-analyzer-*"
> - checks += ",-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
> +
> + # List of checks to be excluded
> + exclude = []
> + exclude.append("-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling")
> +
> + checks += ''.join(["," + e for e in exclude])

Thanks for the patch. I think it's more canonical Python to do:

checks += ",".join(exclude)

However, let's just make `checks` a list to start with? Then join it
at the very end?

Even for clang-tidy, we would have a comma separated list:
`"-check=-*,linuxkernel-*"`

> p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]],

^ so then this could be:

p = subprocess.run(["clang-tidy", "-p", args.path, ",".join(checks), ...

> stdout=subprocess.PIPE,
> stderr=subprocess.STDOUT,
> --
> 2.7.4
>


--
Thanks,
~Nick Desaulniers