checkpatch: fix wildcard DT compatible string checking
PATCH 1/2 checkpatch: fix wildcard DT compatible string checking
From: Rob Herring <[email protected]>
We attempt to search for compatible strings which use a variable token in the documented name such as <chip> or <soc>. While this was attempted to be handled, it's utterly broken.
The desired forms of matching are:
vendor,<chip>-*
vendor,name<part#>-*
For <chip>, lower case characters and numbers are permitted. For <part#>, only numeric values are allowed.
With this change, the number of missing compatible strings reported in arch/arm/boot/dts is reduced from 1071 to 960.
--- scripts/checkpatch.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +5 -2
@@ -2093,8 +2093,11 @@ sub process { foreach my $compat (@compats) { my $compat2 = $compat; - $compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/; - `grep -Erq "$compat|$compat2" $dt_path`; + $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/; + my $compat3 = $compat; + $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/; + print "$compat3\n"; + `grep -Erq "$compat|$compat2|$compat3" $dt_path`; if ( $? >> 8 ) { WARN("UNDOCUMENTED_DT_STRING", "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);
Signature · 1 line
1.9.1
PATCH 2/2 checkpatch: skip directories in file checking mode
From: Rob Herring <[email protected]>
Running checkpatch.pl on a list of files using a wildcard will exit if a directory is encountered. For example:
$ scripts/checkpatch.pl -f arch/* diff: arch/alpha/null: No such file or directory
The correct operation is arch/Kconfig should be checked. Fix this by skipping files which are not regular files.
--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
@@ -552,6 +552,7 @@ my $vname; for my $filename (@ARGV) { my $FILE; if ($file) { + next if (!(-f $filename)); open($FILE, '-|', "diff -u /dev/null $filename") || die "$P: $filename: diff failed - $!\n"; } elsif ($filename eq '-') {
Signature · 1 line
1.9.1
Joe Perches
maintainerRe: [PATCH 2/2] checkpatch: skip directories in file checking mode
Quoted 10 lines · Rob Herring
From: Rob Herring <[email protected]>
Running checkpatch.pl on a list of files using a wildcard will exit if a directory is encountered. For example:
$ scripts/checkpatch.pl -f arch/* diff: arch/alpha/null: No such file or directoryThe correct operation is
arch/Kconfigshould be checked. Fix this by skipping files which are not regular files.
<shrug>
You could make the same argument that it should
skip .o files if you fed it to checkpatch on the
command line.
I think the correct thing is to feed only files
you want scanned to checkpatch.
git ls-files arch/ | xargs ./scripts/checkpatch.pl -f
Joe Perches
maintainerQuoted 3 lines · Rob Herring
We attempt to search for compatible strings which use a variable token in the documented name such as <chip> or <soc>. While this was attempted to be handled, it's utterly broken.
Looks like you've left some debugging stuff in this patch.
Quoted 10 lines
The desired forms of matching are:
vendor,<chip>-*
vendor,name<part#>-*scripts/checkpatch.pl +0
-0
scripts/checkpatch.pl sub process { · line 2099
Quoted 9 lines
scripts/checkpatch.pl +4
-2@@ -2093,8 +2093,11 @@ sub process { foreach my $compat (@compats) { my $compat2 = $compat; - $compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/; - `grep -Erq "$compat|$compat2" $dt_path`; + $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/; + my $compat3 = $compat; + $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/; + print "$compat3\n";
debugging code?
Quoted 4 lines
scripts/checkpatch.pl +1
-0+ `grep -Erq "$compat|$compat2|$compat3" $dt_path`; if ( $? >> 8 ) { WARN("UNDOCUMENTED_DT_STRING", "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);