update checkpatch to v0.28
Andy Whitcroft
maintainercover update checkpatch to v0.28
Here is the next batch of updates for checkpatch. These have passed testing here, I have some more stuff you sent me pending and will get you another update out next week hopefully with those.
This update brings an a number of fixes mostly relating to the handling of modifiers. Of note:
- multiple modifier handling fixes, and
- do not warn about -p0 patches when using --file
Complete changelog below.
-apw
Andy Whitcroft (8):
checkpatch: make in_atomic ok in the core
checkpatch: do not warn about -p0 patches when checking files
checkpatch: correctly handle type spacing in the face of modifiers
checkpatch: pointer type star may have modifiers following
checkpatch: a modifier is not an identifier at the end of a type
checkpatch: extend attribute testing to all modifiers
checkpatch: add __ref as a sparse modifier
checkpatch: version 0.28
scripts/checkpatch.pl | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-)
Andy Whitcroft
maintainerPATCH 1/8 checkpatch: make in_atomic ok in the core
We say that in_atomic() is ok in the core kernel, but then always report it regardless of where in the kernel it is. Keep quiet if it is used in kernel/*.
--- scripts/checkpatch.pl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/checkpatch.pl +1 -1
@@ -2560,7 +2560,7 @@ sub process { if ($line =~ /\bin_atomic\s*\(/) { if ($realfile =~ m@^drivers/@) { ERROR("do not use in_atomic in drivers\n" . $herecurr); - } else { + } elsif ($realfile !~ m@^kernel/@) { WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); } }
Signature · 1 line
1.6.1.2.419.g0d87e
Andy Whitcroft
maintainerPATCH 2/8 checkpatch: do not warn about -p0 patches when checking files
In reply to Andy WhitcroftWe are triggering the -p0 check for our own diffs generated using --file command line option. Suppress this check for files.
--- scripts/checkpatch.pl | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
scripts/checkpatch.pl +2 -1
@@ -1240,7 +1240,8 @@ sub process { $realfile =~ s@^([^/]*)/@@; $p1_prefix = $1; - if ($tree && $p1_prefix ne '' && -e "$root/$p1_prefix") { + if (!$file && $tree && $p1_prefix ne '' && + -e "$root/$p1_prefix") { WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n"); }
Signature · 1 line
1.6.1.2.419.g0d87e
Andy Whitcroft
maintainerPATCH 3/8 checkpatch: correctly handle type spacing in the face of modifiers
In reply to Andy WhitcroftWe need to handle interspersed modifiers in the middle of pointer types, for example:
void * __user * __user bar;
--- scripts/checkpatch.pl | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
@@ -1658,7 +1658,7 @@ sub process { # * goes on variable not on type # (char*[ const]) - if ($line =~ m{\($NonptrType(\s*\*[\s\*]*(?:$Modifier\s*)*)\)}) { + if ($line =~ m{\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\)}) { my ($from, $to) = ($1, $1); # Should start with a space.
@@ -1673,7 +1673,7 @@ sub process { if ($from ne $to) { ERROR("\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); } - } elsif ($line =~ m{\b$NonptrType(\s*\*[\s\*]*(?:$Modifier\s*)?)($Ident)}) { + } elsif ($line =~ m{\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident)}) { my ($from, $to, $ident) = ($1, $1, $2); # Should start with a space.
Signature · 1 line
1.6.1.2.419.g0d87e
Andy Whitcroft
maintainerPATCH 4/8 checkpatch: pointer type star may have modifiers following
In reply to Andy WhitcroftWe may have any modifier following a pointer type star. Handle this:
void * __user * __user foo;
--- scripts/checkpatch.pl | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
@@ -1886,11 +1886,11 @@ sub process { if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { ERROR("space required before that '$op' $at\n" . $hereptr); } - if ($op eq '*' && $cc =~/\s*const\b/) { + if ($op eq '*' && $cc =~/\s*$Modifier\b/) { # A unary '*' may be const } elsif ($ctx =~ /.xW/) { - ERROR("space prohibited after that '$op' $at\n" . $hereptr); + ERROR("Aspace prohibited after that '$op' $at\n" . $hereptr); } # unary ++ and unary -- are allowed no space on one side.
Signature · 1 line
1.6.1.2.419.g0d87e
Andy Whitcroft
maintainerPATCH 5/8 checkpatch: a modifier is not an identifier at the end of a type
In reply to Andy WhitcroftWe must make sure we do not miss recognise a modifier as an Identifier when trying to match types. Prevent us matching this:
void * __ref
--- scripts/checkpatch.pl | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
@@ -1686,8 +1686,8 @@ sub process { # Modifiers should have spaces. $to =~ s/(\b$Modifier$)/$1 /; - #print "from<$from> to<$to>\n"; - if ($from ne $to) { + #print "from<$from> to<$to> ident<$ident>\n"; + if ($from ne $to && $ident !~ /^$Modifier$/) { ERROR("\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr); } }
Signature · 1 line
1.6.1.2.419.g0d87e
Andy Whitcroft
maintainerPATCH 6/8 checkpatch: extend attribute testing to all modifiers
In reply to Andy WhitcroftWe should allow testing of all modifiers not just attributes. Extend testing and test for all the know modifiers.
--- scripts/checkpatch.pl | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
@@ -1584,9 +1584,9 @@ sub process { } # TEST: allow direct testing of the attribute matcher. if ($dbg_attr) { - if ($line =~ /^.\s*$Attribute\s*$/) { + if ($line =~ /^.\s*$Modifier\s*$/) { ERROR("TEST: is attr\n" . $herecurr); - } elsif ($dbg_attr > 1 && $line =~ /^.+($Attribute)/) { + } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) { ERROR("TEST: is not attr ($1 is)\n". $herecurr); } next;
Signature · 1 line
1.6.1.2.419.g0d87e
Andy Whitcroft
maintainerPATCH 7/8 checkpatch: add __ref as a sparse modifier
In reply to Andy WhitcroftAdd __ref as a sparse modifier.
--- scripts/checkpatch.pl | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
scripts/checkpatch.pl +2 -1
@@ -110,7 +110,8 @@ our $Sparse = qr{ __iomem| __must_check| __init_refok| - __kprobes + __kprobes| + __ref }x; our $Attribute = qr{ const|
Signature · 1 line
1.6.1.2.419.g0d87e
Andy Whitcroft
maintainerPATCH 8/8 checkpatch: version 0.28
In reply to Andy Whitcroft--- scripts/checkpatch.pl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/checkpatch.pl +1 -1
@@ -10,7 +10,7 @@ use strict; my $P = $0; $P =~ s@.*/@@g; -my $V = '0.27'; +my $V = '0.28'; use Getopt::Long qw(:config no_auto_abbrev);
Signature · 1 line
1.6.1.2.419.g0d87e