Skip to contentSkip to conversation

checkpatch: ignore /dev/null being added for file path checks

PATCH In review Jonas Gorski 2 participants 2 messages Jul 15, 2023 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: ignore /dev/null being added for file path checks

In e.g. schema to yaml conversion patches, a file may be deleted, causing checkpatch in strict mode to complain about files outside of the bindings directory being modified:

./scripts/checkpatch.pl --strict --showfile 0001-dt-bindings-spi-convert-spi-brcm63xx.txt-to-YAML.patch
dev/null:72: WARNING: DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.rst
total: 0 errors, 1 warnings, 0 checks, 79 lines checked

Since this isn't a real file, skip any further checks based on the file's location.

Fixes 133712a2ec84 ("checkpatch: DT bindings should be a separate patch")
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
index 880fde13d9b8..30de47909460 100755
@@ -2856,6 +2856,12 @@ sub process {
 			$realfile =~ s@^([^/]*)/@@ if (!$file);
 			$in_commit_log = 0;
 
+			# "/dev/null" being added means a file was actually
+			# deleted, no need for further file location checks
+			if ($line eq "+++ /dev/null") {
+				next;
+			}
+
 			$p1_prefix = $1;
 			if (!$file && $tree && $p1_prefix ne '' &&
 			    -e "$root/$p1_prefix") {
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 5 lines · Jonas Gorski

In e.g. schema to yaml conversion patches, a file may be deleted, causing checkpatch in strict mode to complain about files outside of the bindings directory being modified:

  ./scripts/checkpatch.pl --strict --showfile 0001-dt-bindings-spi-convert-spi-brcm63xx.txt-to-YAML.patch

Please send this patch file

Quoted 31 lines

dev/null:72: WARNING: DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.rst
total: 0 errors, 1 warnings, 0 checks, 79 lines checked

Since this isn't a real file, skip any further checks based on the file's location.

Fixes 133712a2ec84 ("checkpatch: DT bindings should be a separate patch")
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
index 880fde13d9b8..30de47909460 100755
@@ -2856,6 +2856,12 @@ sub process {
 			$realfile =~ s@^([^/]*)/@@ if (!$file);
 			$in_commit_log = 0;
 
+			# "/dev/null" being added means a file was actually
+			# deleted, no need for further file location checks
+			if ($line eq "+++ /dev/null") {
+				next;
+			}
+
 			$p1_prefix = $1;
 			if (!$file && $tree && $p1_prefix ne '' &&
 			    -e "$root/$p1_prefix") {