[Linux-kernel-mentees] [PATCH] checkpatch: add --fix option for INCLUDE_LINUX
Lukas Bulwahn
lukas.bulwahn at gmail.com
Sat Nov 21 09:45:06 UTC 2020
On Sat, Nov 21, 2020 at 9:09 AM Dwaipayan Ray <dwaipayanray1 at gmail.com> wrote:
>
> Provide fix option to INCLUDE_LINUX check to replace asm
> includes.
>
> Macros of type:
> #include <asm/percpu.h>
>
> are corrected to:
> #include <linux/percpu.h>
>
The patch itself looks okay; but should this fix option not be limited
to lines where content is added?
Further we need to investigate:
- is this still a valid rule?
- is this rule and the rationale documented somewhere?
- how many rule violations currently exist in the kernel repository?
- are there known exceptions for some files in some directories?
Lukas
> Signed-off-by: Dwaipayan Ray <dwaipayanray1 at gmail.com>
> ---
> scripts/checkpatch.pl | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 0da6422cd0fd..f852f130e065 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5468,8 +5468,11 @@ sub process {
> CHK("ARCH_INCLUDE_LINUX",
> "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
> } 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/\<asm\/$file\>/\<linux\/$file\>/;
> + }
> }
> }
> }
> --
> 2.27.0
>
More information about the Linux-kernel-mentees
mailing list