From f4a8773676c21a68b0666fbe48af4fe1af89dfa9 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 27 Feb 2009 14:03:05 -0800 Subject: 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/*. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 45eb0ae98eba..c71a0fae84df 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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); } } -- cgit v1.2.2 From e2f7aa4b8bc811ebf8afbdf423caf90a5a03cb08 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 27 Feb 2009 14:03:06 -0800 Subject: checkpatch: do not warn about -p0 patches when checking files We are triggering the -p0 check for our own diffs generated using --file command line option. Suppress this check for files. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c71a0fae84df..5ffc940399be 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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"); } -- cgit v1.2.2 From 00ef4ece05096a5c523e265b8ce6627fb5e171c2 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 27 Feb 2009 14:03:07 -0800 Subject: checkpatch: correctly handle type spacing in the face of modifiers We need to handle interspersed modifiers in the middle of pointer types, for example: void * __user * __user bar; Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5ffc940399be..92d13710ff52 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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. -- cgit v1.2.2 From a3340b35787975414d5f6fee83e00640688be2cb Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 27 Feb 2009 14:03:07 -0800 Subject: checkpatch: pointer type star may have modifiers following We may have any modifier following a pointer type star. Handle this: void * __user * __user foo; Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 92d13710ff52..15a590425129 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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. -- cgit v1.2.2 From 667026e7b082ad59eb7194d6b5d159ed6c340e05 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 27 Feb 2009 14:03:08 -0800 Subject: checkpatch: a modifier is not an identifier at the end of a type We must make sure we do not misrecognise a modifier as an Identifier when trying to match types. Prevent us matching this: void * __ref Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 15a590425129..b9e9ee1315b7 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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); } } -- cgit v1.2.2 From 9360b0e50e9f3e0fd70a077b4ede9885ebc21720 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 27 Feb 2009 14:03:08 -0800 Subject: checkpatch: extend attribute testing to all modifiers We should allow testing of all modifiers not just attributes. Extend testing and test for all the know modifiers. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b9e9ee1315b7..0dcfdce632b1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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; -- cgit v1.2.2 From 417495eda3ce50f9c6d28f8e9ddb3bbb25f07f4c Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 27 Feb 2009 14:03:08 -0800 Subject: checkpatch: add __ref as a sparse modifier Add __ref as a sparse modifier. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0dcfdce632b1..60ad8dbd79e1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -110,7 +110,8 @@ our $Sparse = qr{ __iomem| __must_check| __init_refok| - __kprobes + __kprobes| + __ref }x; our $Attribute = qr{ const| -- cgit v1.2.2 From bea5606d08a36a5fdcf815073d3593ddd2c8549e Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 27 Feb 2009 14:03:09 -0800 Subject: checkpatch: version 0.28 Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 60ad8dbd79e1..2d5ece798c4c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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); -- cgit v1.2.2