qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] scripts/checkpatch: emit a warning if an imported file is to


From: Stefano Garzarella
Subject: Re: [PATCH] scripts/checkpatch: emit a warning if an imported file is touched
Date: Wed, 17 Jul 2024 14:26:52 +0200

On Wed, Jul 17, 2024 at 10:50:51AM GMT, Daniel P. Berrangé wrote:
On Wed, Jul 17, 2024 at 11:37:52AM +0200, Stefano Garzarella wrote:
If a file imported from Linux is touched, emit a warning and suggest
using scripts/update-linux-headers.sh

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
 scripts/checkpatch.pl | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ff373a7083..b0e8266fa2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1374,6 +1374,7 @@ sub process {
        my $in_header_lines = $file ? 0 : 1;
        my $in_commit_log = 0;          #Scanning lines before patch
        my $reported_maintainer_file = 0;
+       my $reported_imported_file = 0;
        my $non_utf8_charset = 0;

        our @report = ();
@@ -1673,8 +1674,17 @@ sub process {
 # ignore non-hunk lines and lines being removed
                next if (!$hunk_line || $line =~ /^-/);

-# ignore files that are being periodically imported from Linux
-               next if ($realfile =~ 
/^(linux-headers|include\/standard-headers)\//);
+# ignore files that are being periodically imported from Linux and emit a 
warning
+               if ($realfile =~ 
/^(linux-headers|include\/standard-headers)\//) {
+                       if (!$reported_imported_file) {
+                               $reported_imported_file = 1;
+                               WARN("added, moved or deleted file(s) " .
+                                    "imported from Linux, are you using " .
+                                    "scripts/update-linux-headers.sh?\n" .
+                                    $herecurr);

This is a good hint, but can we add a further check that is a fatal error,
if the headers are changed in the same commit as non-header changes. When
importing headers, they should only ever be in a self-contained patch
with nothing else touched.

Yep, good point! I'll add that check in v2.

Thanks,
Stefano




reply via email to

[Prev in Thread] Current Thread [Next in Thread]