[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKXUXMxD9wyaKf1TrZchOY1NBkFKSrHhFefQc9AK-bfH8fu8oA@mail.gmail.com>
Date: Wed, 9 Dec 2020 10:17:59 +0100
From: Lukas Bulwahn <lukas.bulwahn@...il.com>
To: Dwaipayan Ray <dwaipayanray1@...il.com>
Cc: Joe Perches <joe@...ches.com>,
linux-kernel-mentees@...ts.linuxfoundation.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] checkpatch: add --fix option to include linux checks
On Sun, Dec 6, 2020 at 4:24 PM Dwaipayan Ray <dwaipayanray1@...il.com> wrote:
>
> Add fix option to INCLUDE_LINUX and ARCH_INCLUDE_LINUX
> checks to replace asm includes.
>
> Macros of type:
> #include <asm/percpu.h>
> #include <asm/processor.h>
>
> are corrected to:
> #include <linux/percpu.h>
> #include <linux/processor.h>
>
> Signed-off-by: Dwaipayan Ray <dwaipayanray1@...il.com>
Dwaipayan, can you run this rule from checkpatch.pl on all files in
the current linux-next tree and share all findings with me?
Maybe, we can fix a few places and improve the rule.
Lukas
> ---
> Changes in v3:
> - Add --fix option to ARCH_INCLUDE_LINUX check
>
> Changes in v2:
> - Use \Q..\E quoting
> - Use @ as regex delimiter
>
> scripts/checkpatch.pl | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7b086d1cd6c2..4aecc237ed38 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5558,11 +5558,17 @@ sub process {
> my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
> if ($asminclude > 0) {
> if ($realfile =~ m{^arch/}) {
> - CHK("ARCH_INCLUDE_LINUX",
> - "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
> + if (CHK("ARCH_INCLUDE_LINUX",
> + "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr) &&
> + $fix) {
> + $fixed[$fixlinenr] =~ s@\Q<asm/$file>\E@<linux/$file>@;
> + }
> } else {
> - WARN("INCLUDE_LINUX",
> - "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
> + if (WARN("INCLUDE_LINUX",
> + "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr) &&
> + $fix) {
> + $fixed[$fixlinenr] =~ s@\Q<asm/$file>\E@<linux/$file>@;
> + }
> }
> }
> }
> --
> 2.27.0
>
Powered by blists - more mailing lists