mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/8] update checkpatch to v0.28
@ 2009-01-30 15:05 Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 1/8] checkpatch: make in_atomic ok in the core Andy Whitcroft
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

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(-)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/8] checkpatch: make in_atomic ok in the core
  2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
@ 2009-01-30 15:05 ` Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 2/8] checkpatch: do not warn about -p0 patches when checking files Andy Whitcroft
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

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 <apw@canonical.com>
---
 scripts/checkpatch.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 45eb0ae..c71a0fa 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);
 			}
 		}
-- 
1.6.1.2.419.g0d87e


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/8] checkpatch: do not warn about -p0 patches when checking files
  2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 1/8] checkpatch: make in_atomic ok in the core Andy Whitcroft
@ 2009-01-30 15:05 ` Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 3/8] checkpatch: correctly handle type spacing in the face of modifiers Andy Whitcroft
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

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 <apw@canonical.com>
---
 scripts/checkpatch.pl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c71a0fa..5ffc940 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");
 			}
 
-- 
1.6.1.2.419.g0d87e


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/8] checkpatch: correctly handle type spacing in the face of modifiers
  2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 1/8] checkpatch: make in_atomic ok in the core Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 2/8] checkpatch: do not warn about -p0 patches when checking files Andy Whitcroft
@ 2009-01-30 15:05 ` Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 4/8] checkpatch: pointer type star may have modifiers following Andy Whitcroft
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

We need to handle interspersed modifiers in the middle of pointer types,
for example:

	void * __user * __user bar;

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 scripts/checkpatch.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 5ffc940..92d1371 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.
-- 
1.6.1.2.419.g0d87e


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/8] checkpatch: pointer type star may have modifiers following
  2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
                   ` (2 preceding siblings ...)
  2009-01-30 15:05 ` [PATCH 3/8] checkpatch: correctly handle type spacing in the face of modifiers Andy Whitcroft
@ 2009-01-30 15:05 ` Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 5/8] checkpatch: a modifier is not an identifier at the end of a type Andy Whitcroft
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

We may have any modifier following a pointer type star.  Handle this:

	void * __user * __user foo;

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 scripts/checkpatch.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 92d1371..15a5904 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.
-- 
1.6.1.2.419.g0d87e


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/8] checkpatch: a modifier is not an identifier at the end of a type
  2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
                   ` (3 preceding siblings ...)
  2009-01-30 15:05 ` [PATCH 4/8] checkpatch: pointer type star may have modifiers following Andy Whitcroft
@ 2009-01-30 15:05 ` Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 6/8] checkpatch: extend attribute testing to all modifiers Andy Whitcroft
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

We must make sure we do not miss recognise a modifier as an Identifier
when trying to match types.  Prevent us matching this:

	void * __ref

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 scripts/checkpatch.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 15a5904..b9e9ee1 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);
 			}
 		}
-- 
1.6.1.2.419.g0d87e


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/8] checkpatch: extend attribute testing to all modifiers
  2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
                   ` (4 preceding siblings ...)
  2009-01-30 15:05 ` [PATCH 5/8] checkpatch: a modifier is not an identifier at the end of a type Andy Whitcroft
@ 2009-01-30 15:05 ` Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 7/8] checkpatch: add __ref as a sparse modifier Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 8/8] checkpatch: version 0.28 Andy Whitcroft
  7 siblings, 0 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

We should allow testing of all modifiers not just attributes.  Extend
testing and test for all the know modifiers.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 scripts/checkpatch.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b9e9ee1..0dcfdce 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;
-- 
1.6.1.2.419.g0d87e


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 7/8] checkpatch: add __ref as a sparse modifier
  2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
                   ` (5 preceding siblings ...)
  2009-01-30 15:05 ` [PATCH 6/8] checkpatch: extend attribute testing to all modifiers Andy Whitcroft
@ 2009-01-30 15:05 ` Andy Whitcroft
  2009-01-30 15:05 ` [PATCH 8/8] checkpatch: version 0.28 Andy Whitcroft
  7 siblings, 0 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

Add __ref as a sparse modifier.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 scripts/checkpatch.pl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0dcfdce..60ad8db 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|
-- 
1.6.1.2.419.g0d87e


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 8/8] checkpatch: version 0.28
  2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
                   ` (6 preceding siblings ...)
  2009-01-30 15:05 ` [PATCH 7/8] checkpatch: add __ref as a sparse modifier Andy Whitcroft
@ 2009-01-30 15:05 ` Andy Whitcroft
  7 siblings, 0 replies; 9+ messages in thread
From: Andy Whitcroft @ 2009-01-30 15:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 scripts/checkpatch.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 60ad8db..2d5ece7 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);
 
-- 
1.6.1.2.419.g0d87e


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-01-30 15:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-30 15:05 [PATCH 0/8] update checkpatch to v0.28 Andy Whitcroft
2009-01-30 15:05 ` [PATCH 1/8] checkpatch: make in_atomic ok in the core Andy Whitcroft
2009-01-30 15:05 ` [PATCH 2/8] checkpatch: do not warn about -p0 patches when checking files Andy Whitcroft
2009-01-30 15:05 ` [PATCH 3/8] checkpatch: correctly handle type spacing in the face of modifiers Andy Whitcroft
2009-01-30 15:05 ` [PATCH 4/8] checkpatch: pointer type star may have modifiers following Andy Whitcroft
2009-01-30 15:05 ` [PATCH 5/8] checkpatch: a modifier is not an identifier at the end of a type Andy Whitcroft
2009-01-30 15:05 ` [PATCH 6/8] checkpatch: extend attribute testing to all modifiers Andy Whitcroft
2009-01-30 15:05 ` [PATCH 7/8] checkpatch: add __ref as a sparse modifier Andy Whitcroft
2009-01-30 15:05 ` [PATCH 8/8] checkpatch: version 0.28 Andy Whitcroft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®