qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Subject: [PULL 1/8] scripts/checkpatch.pl: remove bogus patch prefix warning
Date: Tue,  4 Nov 2025 17:30:55 +0100	[thread overview]
Message-ID: <20251104163102.738889-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20251104163102.738889-1-pbonzini@redhat.com>

From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>

Remove the 'patch prefix exists, appears to be a -p0 patch' warning
entirely as it is fundamentally flawed and can only produce false
positives.

Sometimes I create test files with names 'a' and 'b', and then get
surprised seeing this warning. It was not easy to understand where it
comes from.

How it works:
1. It extracts prefixes (a/, b/) from standard diff output
2. Checks if files/directories with these names exist in the project
   root
3. Warns if they exist, claiming it's a '-p0 patch' issue

This logic is wrong because:
- Standard diff/patch tools always use a/ and b/ prefixes by default
- The existence of files named 'a' or 'b' in the working directory is
  completely unrelated to patch format
- The working directory state may not correspond to the patch content
  (different commits, branches, etc.)
- In QEMU project, there are no single-letter files/directories in root,
  so this check can only generate false positives

The correct way to detect -p0 patches would be to analyze the path
format within the patch itself (e.g., absolute paths or paths without
prefixes), not check filesystem state.

So, let's finally drop it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Link: https://lore.kernel.org/r/20251030201319.858480-1-vsementsov@yandex-team.ru
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/checkpatch.pl | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d3d75f3f139..d0f4537f25e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1741,13 +1741,7 @@ sub process {
 			}
 		} elsif ($line =~ /^\+\+\+\s+(\S+)/) {
 			$realfile = $1;
-			$realfile =~ s@^([^/]*)/@@ if (!$file);
-
-			$p1_prefix = $1;
-			if (!$file && $tree && $p1_prefix ne '' &&
-			    -e "$root/$p1_prefix") {
-				WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
-			}
+			$realfile =~ s@^[^/]*/@@  if (!$file);
 
 			if (defined $fileinfo && !$fileinfo->{isgit}) {
 				$fileinfo->{lineend} = $oldhere;
-- 
2.51.1



  reply	other threads:[~2025-11-04 16:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04 16:30 [PULL 0/8] Cleanup patches for QEMU 10.2 soft freeze Paolo Bonzini
2025-11-04 16:30 ` Paolo Bonzini [this message]
2025-11-04 16:30 ` [PULL 2/8] rust/util: add ensure macro Paolo Bonzini
2025-11-04 16:30 ` [PULL 3/8] rust/util: use anyhow's native chaining capabilities Paolo Bonzini
2025-11-04 16:30 ` [PULL 4/8] rust/util: replace Error::err_or_unit/err_or_else with Error::with_errp Paolo Bonzini
2025-11-04 16:30 ` [PULL 5/8] rust: pull error_fatal out of SysbusDeviceMethods::sysbus_realize Paolo Bonzini
2025-11-04 16:31 ` [PULL 6/8] rust: do not add qemuutil to Rust crates Paolo Bonzini
2025-11-04 16:31 ` [PULL 7/8] rust: migration: allow nested offset_of Paolo Bonzini
2025-11-04 16:31 ` [PULL 8/8] rust: add back to Ubuntu 22.04 jobs Paolo Bonzini
2025-11-05 13:46 ` [PULL 0/8] Cleanup patches for QEMU 10.2 soft freeze Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251104163102.738889-2-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).