linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] checkpatch: allow build files to reference other build files
@ 2024-01-12 18:34 Will McVicker
  2024-01-12 18:48 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Will McVicker @ 2024-01-12 18:34 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn
  Cc: linux-kbuild, Will McVicker, kernel-team, linux-kernel

Add an exception to the EMBEDDED_FILENAME warning for build files. This
fixes the below warnings where the Kconfig and Makefile files reference
other similarly named build files.

  WARNING:EMBEDDED_FILENAME: It's generally not useful to have the
  filename in the file
  #24: FILE: Kconfig:34:
  +source "drivers/willmcvicker/Kconfig"

  WARNING:EMBEDDED_FILENAME: It's generally not useful to have the
  filename in the file
  #36: FILE: Makefile:667:
  +	} > Makefile

Signed-off-by: Will McVicker <willmcvicker@google.com>
---
 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f8343b34a28b..62939f5800cf 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3785,7 +3785,9 @@ sub process {
 		}
 
 # check for embedded filenames
-		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) {
+		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
+			$realfile !~ /Kconfig.*/ &&
+			$realfile !~ /Makefile.*/) {
 			WARN("EMBEDDED_FILENAME",
 			     "It's generally not useful to have the filename in the file\n" . $herecurr);
 		}

base-commit: 70d201a40823acba23899342d62bc2644051ad2e
-- 
2.43.0.275.g3460e3d667-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] checkpatch: allow build files to reference other build files
  2024-01-12 18:34 [PATCH v1] checkpatch: allow build files to reference other build files Will McVicker
@ 2024-01-12 18:48 ` Joe Perches
  2024-01-12 22:16   ` William McVicker
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2024-01-12 18:48 UTC (permalink / raw)
  To: Will McVicker, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn
  Cc: linux-kbuild, kernel-team, linux-kernel

On Fri, 2024-01-12 at 10:34 -0800, Will McVicker wrote:
> Add an exception to the EMBEDDED_FILENAME warning for build files. This
> fixes the below warnings where the Kconfig and Makefile files reference
> other similarly named build files.
> 
>   WARNING:EMBEDDED_FILENAME: It's generally not useful to have the
>   filename in the file
>   #24: FILE: Kconfig:34:
>   +source "drivers/willmcvicker/Kconfig"
> 
>   WARNING:EMBEDDED_FILENAME: It's generally not useful to have the
>   filename in the file
>   #36: FILE: Makefile:667:
>   +	} > Makefile

No need to wrap here I think.

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3785,7 +3785,9 @@ sub process {
>  		}
>  
>  # check for embedded filenames
> -		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) {
> +		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
> +			$realfile !~ /Kconfig.*/ &&
> +			$realfile !~ /Makefile.*/) {

Align to open parenthesis please.
It's not useful to have .* before the /

So perhaps better to be

		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
		    $realfile !~ /(?:Kconfig|Makefile)/) {
	
>  			WARN("EMBEDDED_FILENAME",
>  			     "It's generally not useful to have the filename in the file\n" . $herecurr);
>  		}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] checkpatch: allow build files to reference other build files
  2024-01-12 18:48 ` Joe Perches
@ 2024-01-12 22:16   ` William McVicker
  0 siblings, 0 replies; 3+ messages in thread
From: William McVicker @ 2024-01-12 22:16 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn, linux-kbuild,
	kernel-team, linux-kernel

On 01/12/2024, Joe Perches wrote:
> On Fri, 2024-01-12 at 10:34 -0800, Will McVicker wrote:
> > Add an exception to the EMBEDDED_FILENAME warning for build files. This
> > fixes the below warnings where the Kconfig and Makefile files reference
> > other similarly named build files.
> > 
> >   WARNING:EMBEDDED_FILENAME: It's generally not useful to have the
> >   filename in the file
> >   #24: FILE: Kconfig:34:
> >   +source "drivers/willmcvicker/Kconfig"
> > 
> >   WARNING:EMBEDDED_FILENAME: It's generally not useful to have the
> >   filename in the file
> >   #36: FILE: Makefile:667:
> >   +	} > Makefile
> 
> No need to wrap here I think.

You're right. I'll update in v2.

> 
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > @@ -3785,7 +3785,9 @@ sub process {
> >  		}
> >  
> >  # check for embedded filenames
> > -		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) {
> > +		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
> > +			$realfile !~ /Kconfig.*/ &&
> > +			$realfile !~ /Makefile.*/) {
> 
> Align to open parenthesis please.
> It's not useful to have .* before the /

I was following other references in this file, but looks like you're right that
it's not needed. Your recommendation passed the tests I have. So I'll update
the regex in v2.

Thanks,
Will

> 
> So perhaps better to be
> 
> 		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
> 		    $realfile !~ /(?:Kconfig|Makefile)/) {
> 	
> >  			WARN("EMBEDDED_FILENAME",
> >  			     "It's generally not useful to have the filename in the file\n" . $herecurr);
> >  		}
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-12 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-12 18:34 [PATCH v1] checkpatch: allow build files to reference other build files Will McVicker
2024-01-12 18:48 ` Joe Perches
2024-01-12 22:16   ` William McVicker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).