* [PATCH 1/6] checkpatch: handle missing #if open in context
2009-01-12 12:44 [PATCH 0/6] update checkpatch to version 0.27 Andy Whitcroft
@ 2009-01-12 12:44 ` Andy Whitcroft
2009-01-12 12:45 ` [PATCH 2/6] checkpatch: type/cast spacing should not check prefix spacing Andy Whitcroft
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andy Whitcroft @ 2009-01-12 12:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft
If the #if opening statement is not in the context then the context
stack can be empty. Handle this by ensuring there is always a blank
entry in the stack.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Tested-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
---
scripts/checkpatch.pl | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7bed4ed..eefef65 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -411,13 +411,15 @@ sub ctx_statement_block {
my $type = '';
my $level = 0;
- my @stack = ([$type, $level]);
+ my @stack = ();
my $p;
my $c;
my $len = 0;
my $remainder;
while (1) {
+ @stack = (['', 0]) if ($#stack == -1);
+
#warn "CSB: blk<$blk> remain<$remain>\n";
# If we are about to drop off the end, pull in more
# context.
--
1.6.0.4.911.gc990
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 2/6] checkpatch: type/cast spacing should not check prefix spacing
2009-01-12 12:44 [PATCH 0/6] update checkpatch to version 0.27 Andy Whitcroft
2009-01-12 12:44 ` [PATCH 1/6] checkpatch: handle missing #if open in context Andy Whitcroft
@ 2009-01-12 12:45 ` Andy Whitcroft
2009-01-12 12:45 ` [PATCH 3/6] checkpatch: allow parentheses on return handle array values Andy Whitcroft
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andy Whitcroft @ 2009-01-12 12:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft
We should not be complaining about the prefix spacing for types and
casts. We are triggering here because the check for spacing between
'*'s is overly loose. Tighten this up.
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 eefef65..1d7924a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1665,7 +1665,7 @@ sub process {
# Should not end with a space.
$to =~ s/\s+$//;
# '*'s should not have spaces between.
- while ($to =~ s/(.)\s\*/$1\*/) {
+ while ($to =~ s/\*\s+\*/\*\*/) {
}
#print "from<$from> to<$to>\n";
@@ -1680,7 +1680,7 @@ sub process {
# Should not end with a space.
$to =~ s/\s+$//;
# '*'s should not have spaces between.
- while ($to =~ s/(.)\s\*/$1\*/) {
+ while ($to =~ s/\*\s+\*/\*\*/) {
}
# Modifiers should have spaces.
$to =~ s/(\b$Modifier$)/$1 /;
--
1.6.0.4.911.gc990
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 3/6] checkpatch: allow parentheses on return handle array values
2009-01-12 12:44 [PATCH 0/6] update checkpatch to version 0.27 Andy Whitcroft
2009-01-12 12:44 ` [PATCH 1/6] checkpatch: handle missing #if open in context Andy Whitcroft
2009-01-12 12:45 ` [PATCH 2/6] checkpatch: type/cast spacing should not check prefix spacing Andy Whitcroft
@ 2009-01-12 12:45 ` Andy Whitcroft
2009-01-12 12:45 ` [PATCH 4/6] checkpatch: if should not continue a preceeding brace Andy Whitcroft
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andy Whitcroft @ 2009-01-12 12:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft
When we allow return to have surrounding parentheses when containing
comparison operators we are not correctly handling the case where
the values contain array sufffixes. Squash them.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
scripts/checkpatch.pl | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1d7924a..696196e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2016,7 +2016,11 @@ sub process {
# Flatten any parentheses
$value =~ s/\)\(/\) \(/g;
- while ($value !~ /(?:$Ident|-?$Constant)\s*$Compare\s*(?:$Ident|-?$Constant)/ && $value =~ s/\([^\(\)]*\)/1/) {
+ while ($value =~ s/\[[^\{\}]*\]/1/ ||
+ $value !~ /(?:$Ident|-?$Constant)\s*
+ $Compare\s*
+ (?:$Ident|-?$Constant)/x &&
+ $value =~ s/\([^\(\)]*\)/1/) {
}
if ($value =~ /^(?:$Ident|-?$Constant)$/) {
--
1.6.0.4.911.gc990
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 4/6] checkpatch: if should not continue a preceeding brace
2009-01-12 12:44 [PATCH 0/6] update checkpatch to version 0.27 Andy Whitcroft
` (2 preceding siblings ...)
2009-01-12 12:45 ` [PATCH 3/6] checkpatch: allow parentheses on return handle array values Andy Whitcroft
@ 2009-01-12 12:45 ` Andy Whitcroft
2009-01-12 12:45 ` [PATCH 5/6] checkpatch: struct seq_operations should normally be const Andy Whitcroft
2009-01-12 12:45 ` [PATCH 6/6] checkpatch: version: 0.27 Andy Whitcroft
5 siblings, 0 replies; 7+ messages in thread
From: Andy Whitcroft @ 2009-01-12 12:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft
We should not be continuing a braced section with an if, for example:
if (...) {
} if (...) {
}
Detect this and suggest adding a newline.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
scripts/checkpatch.pl | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 696196e..5ea55e3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2108,6 +2108,11 @@ sub process {
ERROR("trailing statements should be on next line\n" . $herecurr);
}
}
+# if should not continue a brace
+ if ($line =~ /}\s*if\b/) {
+ ERROR("trailing statements should be on next line\n" .
+ $herecurr);
+ }
# case and default should not have general statements after them
if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
$line !~ /\G(?:
--
1.6.0.4.911.gc990
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 5/6] checkpatch: struct seq_operations should normally be const
2009-01-12 12:44 [PATCH 0/6] update checkpatch to version 0.27 Andy Whitcroft
` (3 preceding siblings ...)
2009-01-12 12:45 ` [PATCH 4/6] checkpatch: if should not continue a preceeding brace Andy Whitcroft
@ 2009-01-12 12:45 ` Andy Whitcroft
2009-01-12 12:45 ` [PATCH 6/6] checkpatch: version: 0.27 Andy Whitcroft
5 siblings, 0 replies; 7+ messages in thread
From: Andy Whitcroft @ 2009-01-12 12:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel, Andy Whitcroft
In the general use case struct seq_operations should be a const object.
Check for and warn where it is not.
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
scripts/checkpatch.pl | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 5ea55e3..447435c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2527,9 +2527,10 @@ sub process {
WARN("please use device_initcall() instead of __initcall()\n" . $herecurr);
}
# check for struct file_operations, ensure they are const.
- if ($line =~ /\bstruct\s+file_operations\b/ &&
- $line !~ /\bconst\b/) {
- WARN("struct file_operations should normally be const\n" . $herecurr);
+ if ($line !~ /\bconst\b/ &&
+ $line =~ /\bstruct\s+(file_operations|seq_operations)\b/) {
+ WARN("struct $1 should normally be const\n" .
+ $herecurr);
}
# use of NR_CPUS is usually wrong
--
1.6.0.4.911.gc990
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 6/6] checkpatch: version: 0.27
2009-01-12 12:44 [PATCH 0/6] update checkpatch to version 0.27 Andy Whitcroft
` (4 preceding siblings ...)
2009-01-12 12:45 ` [PATCH 5/6] checkpatch: struct seq_operations should normally be const Andy Whitcroft
@ 2009-01-12 12:45 ` Andy Whitcroft
5 siblings, 0 replies; 7+ messages in thread
From: Andy Whitcroft @ 2009-01-12 12:45 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 447435c..45eb0ae 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -10,7 +10,7 @@ use strict;
my $P = $0;
$P =~ s@.*/@@g;
-my $V = '0.26';
+my $V = '0.27';
use Getopt::Long qw(:config no_auto_abbrev);
--
1.6.0.4.911.gc990
^ permalink raw reply [flat|nested] 7+ messages in thread