mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Fix bad FILE_PATH_CHANGES on headers
@ 2026-11-07 15:02 Pierre-Clément Tosi
  2026-11-08  2:17 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Pierre-Clément Tosi @ 2026-11-07 15:02 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Andrew Morton
  Cc: linux-kernel, Pierre-Clément Tosi

The FILE_PATH_CHANGES warning ("added, moved or deleted file(s), does
MAINTAINERS need updating?") added by commit 13f1937ef339 ("checkpatch:
emit a warning on file add/move/delete") was guarded by !$in_commit_log
so that commit message lines would not be mistaken for diffstat or diff
header lines.

However, it was still evaluated on the initial email header lines
($in_header_lines == 1) such that a title using the rename notation e.g.

    Subject: [PATCH] foo: rework bar_{get=>set}_baz()

triggers a false-positive warning. Furthermore, that same (wrong) code
path sets $is_patch prematurely.

Instead, only test for FILE_PATH_CHANGES when !$in_header_lines.

Fixes: 13f1937ef339 ("checkpatch: emit a warning on file add/move/delete")
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b8b64f720191..03e3e4b72cdd 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3481,7 +3481,7 @@ sub process {
 		}
 
 # Check for added, moved or deleted files
-		if (!$reported_maintainer_file && !$in_commit_log &&
+		if (!$reported_maintainer_file && !$in_commit_log && !$in_header_lines &&
 		    ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
 		     $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
 		     ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261107-checkpatch-file_path_changes-ac920c85bc7e

Best regards,
-- 
Pierre-Clément Tosi <ptosi@google.com>


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

* Re: [PATCH] checkpatch: Fix bad FILE_PATH_CHANGES on headers
  2026-11-07 15:02 [PATCH] checkpatch: Fix bad FILE_PATH_CHANGES on headers Pierre-Clément Tosi
@ 2026-11-08  2:17 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2026-11-08  2:17 UTC (permalink / raw)
  To: Pierre-Clément Tosi, Andy Whitcroft, Andrew Morton; +Cc: linux-kernel

On Sat, 2026-11-07 at 16:02 +0100, Pierre-Clément Tosi wrote:
> The FILE_PATH_CHANGES warning ("added, moved or deleted file(s), does
> MAINTAINERS need updating?") added by commit 13f1937ef339 ("checkpatch:
> emit a warning on file add/move/delete") was guarded by !$in_commit_log
> so that commit message lines would not be mistaken for diffstat or diff
> header lines.
> 
> However, it was still evaluated on the initial email header lines
> ($in_header_lines == 1) such that a title using the rename notation e.g.
> 
>     Subject: [PATCH] foo: rework bar_{get=>set}_baz()
> 
> triggers a false-positive warning. Furthermore, that same (wrong) code
> path sets $is_patch prematurely.

cute.  Thanks again.

Acked-by: Joe Perches <joe@perches.com>

> 
> Instead, only test for FILE_PATH_CHANGES when !$in_header_lines.
> 
> Fixes: 13f1937ef339 ("checkpatch: emit a warning on file add/move/delete")
> Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
> ---
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index b8b64f720191..03e3e4b72cdd 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3481,7 +3481,7 @@ sub process {
>  		}
>  
>  # Check for added, moved or deleted files
> -		if (!$reported_maintainer_file && !$in_commit_log &&
> +		if (!$reported_maintainer_file && !$in_commit_log && !$in_header_lines &&
>  		    ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
>  		     $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
>  		     ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
> 
> ---
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> change-id: 20261107-checkpatch-file_path_changes-ac920c85bc7e
> 
> Best regards,

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

end of thread, other threads:[~2026-11-08  2:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 15:02 [PATCH] checkpatch: Fix bad FILE_PATH_CHANGES on headers Pierre-Clément Tosi
2026-11-08  2:17 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®