* [PATCH 1/2] checkpatch: fix up complex macros context format
@ 2011-12-01 9:33 Andy Whitcroft
2011-12-01 9:33 ` [PATCH 2/2] checkpatch: catch all occurances of type and cast spacing errors per line Andy Whitcroft
0 siblings, 1 reply; 2+ messages in thread
From: Andy Whitcroft @ 2011-12-01 9:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: Joe Perches, linux-kernel, Andy Whitcroft
Fix a missing newline and correctly use the raw context for the
complex macro report.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
scripts/checkpatch.pl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
This could be considered to be a fix for:
checkpatch-correctly-track-the-end-of-preprocessor-commands-in-context.patch
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e29eeea..331e832 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2854,7 +2854,7 @@ sub process {
"Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
} else {
ERROR("COMPLEX_MACRO",
- "Macros with complex values should be enclosed in parenthesis\n" . "$here$ctx");
+ "Macros with complex values should be enclosed in parenthesis\n" . "$herectx");
}
}
}
--
1.7.5.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] checkpatch: catch all occurances of type and cast spacing errors per line
2011-12-01 9:33 [PATCH 1/2] checkpatch: fix up complex macros context format Andy Whitcroft
@ 2011-12-01 9:33 ` Andy Whitcroft
0 siblings, 0 replies; 2+ messages in thread
From: Andy Whitcroft @ 2011-12-01 9:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: Joe Perches, linux-kernel, Andy Whitcroft
Fix up type and cast spacing checks such that all occurances on a line are
examined and reported. For example the line below has a valid cast and
a bad type, but currently we check the cast first which is good and stop:
u16* bar = (u16 *)baz;
We will also only report one of the errors in this example:
u16* bar = (u16*)bad;
Move to iterating across all casts and all types, reporting any failure.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
scripts/checkpatch.pl | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 331e832..4ac397b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2206,8 +2206,9 @@ sub process {
# * goes on variable not on type
# (char*[ const])
- if ($line =~ m{\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\)}) {
- my ($from, $to) = ($1, $1);
+ while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
+ #print "AA<$1>\n";
+ my ($from, $to) = ($2, $2);
# Should start with a space.
$to =~ s/^(\S)/ $1/;
@@ -2222,8 +2223,10 @@ sub process {
ERROR("POINTER_LOCATION",
"\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr);
}
- } elsif ($line =~ m{\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident)}) {
- my ($from, $to, $ident) = ($1, $1, $2);
+ }
+ while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
+ #print "BB<$1>\n";
+ my ($from, $to, $ident) = ($2, $2, $3);
# Should start with a space.
$to =~ s/^(\S)/ $1/;
--
1.7.5.4
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-01 9:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-01 9:33 [PATCH 1/2] checkpatch: fix up complex macros context format Andy Whitcroft
2011-12-01 9:33 ` [PATCH 2/2] checkpatch: catch all occurances of type and cast spacing errors per line 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®