diff mbox series

[5/7] checkpatch: warn if <asm/export.h> is included

Message ID 20220610183236.1272216-6-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL() | expand

Commit Message

Masahiro Yamada June 10, 2022, 6:32 p.m. UTC
With the previous refactoring,

 - <asm/export.h> is a wrapper of <asm-generic/export.h>
 - <asm-generic/export.h> is a wrapper of <linux/export.h>

My hope is to replace

   #include <asm/export.h>  -->  #include <linux/export.h>

for all *.S files.

For now, adding a warning in the checkpatch.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Joe Perches June 11, 2022, 1:33 a.m. UTC | #1
On Sat, 2022-06-11 at 03:32 +0900, Masahiro Yamada wrote:
> With the previous refactoring,
> 
>  - <asm/export.h> is a wrapper of <asm-generic/export.h>
>  - <asm-generic/export.h> is a wrapper of <linux/export.h>
> 
> My hope is to replace
> 
>    #include <asm/export.h>  -->  #include <linux/export.h>
> 
> for all *.S files.
> 
> For now, adding a warning in the checkpatch.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/checkpatch.pl | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3753,6 +3753,13 @@ sub process {
>  			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
>  		}
>  
> +# warn if <asm/export.h> is included.
> +# <asm/export.h> is a wrapper of <linux/export.h>. Please include <linux/export.h> directly.
> +		if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/export\.h\>}) {
> +			WARN("INCLUDE_LINUX_EXPORT",
> +			    "Please include <linux/export.h> instead of <asm/export.h>\n" . $herecurr);
> +		}

This warns on patch context lines.
That's not something checkpatch generally does.

Likely this should use /^\+ rather than /^.

And it's nice to have --fix capability

			if (WARN("etc...") &&
			    $fix) {
				$fixed[$fixlinenr] =~ s/\s*#\s*include\s*\<asm\/export\.h\>/#include <linux/export.h>/;
			}

cheers, Joe
Masahiro Yamada June 11, 2022, 6:56 p.m. UTC | #2
On Sat, Jun 11, 2022 at 10:33 AM Joe Perches <joe@perches.com> wrote:
>
> On Sat, 2022-06-11 at 03:32 +0900, Masahiro Yamada wrote:
> > With the previous refactoring,
> >
> >  - <asm/export.h> is a wrapper of <asm-generic/export.h>
> >  - <asm-generic/export.h> is a wrapper of <linux/export.h>
> >
> > My hope is to replace
> >
> >    #include <asm/export.h>  -->  #include <linux/export.h>
> >
> > for all *.S files.
> >
> > For now, adding a warning in the checkpatch.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  scripts/checkpatch.pl | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > @@ -3753,6 +3753,13 @@ sub process {
> >                            "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
> >               }
> >
> > +# warn if <asm/export.h> is included.
> > +# <asm/export.h> is a wrapper of <linux/export.h>. Please include <linux/export.h> directly.
> > +             if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/export\.h\>}) {
> > +                     WARN("INCLUDE_LINUX_EXPORT",
> > +                         "Please include <linux/export.h> instead of <asm/export.h>\n" . $herecurr);
> > +             }
>
> This warns on patch context lines.
> That's not something checkpatch generally does.
>
> Likely this should use /^\+ rather than /^.
>
> And it's nice to have --fix capability
>
>                         if (WARN("etc...") &&
>                             $fix) {
>                                 $fixed[$fixlinenr] =~ s/\s*#\s*include\s*\<asm\/export\.h\>/#include <linux/export.h>/;
>                         }
>
> cheers, Joe



I retract this patch series because I realized it was breaking ia64.
Please ignore this patch.

Anyway, your expert feedback about checkpatch.pl
was very appreciated. Thank you.
diff mbox series

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 503e8abbb2c1..f824d690a565 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3753,6 +3753,13 @@  sub process {
 			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
 		}
 
+# warn if <asm/export.h> is included.
+# <asm/export.h> is a wrapper of <linux/export.h>. Please include <linux/export.h> directly.
+		if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/export\.h\>}) {
+			WARN("INCLUDE_LINUX_EXPORT",
+			    "Please include <linux/export.h> instead of <asm/export.h>\n" . $herecurr);
+		}
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);