[v2,5/5] checkpatch: ignore a file named b

Message ID 20221123011202.939319-6-elliott@hpe.com
State New
Headers
Series checkpatch: enhance Kconfig parsing |

Commit Message

Elliott, Robert (Servers) Nov. 23, 2022, 1:12 a.m. UTC
  If a file named "b" happens to exist, checkpatch complains
as it parses the patch lines specifying the filenames.

	WARNING: patch prefix 'b' exists, appears to be a -p0 patch

Squelch that by only complaining if that is a directory,
not a regular file, and print the whole path causing concern.
	WARNING: patch prefix './b' exists, appears to be a -p0 patch

Signed-off-by: Robert Elliott <elliott@hpe.com>
---
 scripts/checkpatch.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Joe Perches Nov. 24, 2022, 1:08 a.m. UTC | #1
On Tue, 2022-11-22 at 19:12 -0600, Robert Elliott wrote:
> If a file named "b" happens to exist, checkpatch complains
> as it parses the patch lines specifying the filenames.
> 
> 	WARNING: patch prefix 'b' exists, appears to be a -p0 patch
> 
> Squelch that by only complaining if that is a directory,
> not a regular file, and print the whole path causing concern.
> 	WARNING: patch prefix './b' exists, appears to be a -p0 patch

Seems OK

> 
> Signed-off-by: Robert Elliott <elliott@hpe.com>
> ---
>  scripts/checkpatch.pl | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d11d58e36ee9..5a0252265d3f 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2834,9 +2834,9 @@ sub process {
>  
>  			$p1_prefix = $1;
>  			if (!$file && $tree && $p1_prefix ne '' &&
> -			    -e "$root/$p1_prefix") {
> +			    -d "$root/$p1_prefix") {
>  				WARN("PATCH_PREFIX",
> -				     "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
> +				     "patch prefix '$root/$p1_prefix' exists, appears to be a -p0 patch\n");
>  			}
>  
>  			if ($realfile =~ m@^include/asm/@) {
  

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d11d58e36ee9..5a0252265d3f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2834,9 +2834,9 @@  sub process {
 
 			$p1_prefix = $1;
 			if (!$file && $tree && $p1_prefix ne '' &&
-			    -e "$root/$p1_prefix") {
+			    -d "$root/$p1_prefix") {
 				WARN("PATCH_PREFIX",
-				     "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
+				     "patch prefix '$root/$p1_prefix' exists, appears to be a -p0 patch\n");
 			}
 
 			if ($realfile =~ m@^include/asm/@) {