Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1334906
| From | Jeffrey Merkey <jeffmerkey@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] Add fix case for open braces |
| Date | 2016-02-16 02:30 +0100 |
| Message-ID | <r2CCK-GB-5@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Some quite excellent fixes from Joe Perches that belong
back in the original. Submitting to Joe for inclusion. Joe
was the original author of these fixes that save a lot of time
rewriting code. Thanks Joe.
Signed-off-by: Jeffrey Merkey <jeffmerkey@gmail.com>
---
scripts/checkpatch.pl | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 874132b..71f93e8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3108,9 +3108,15 @@ sub process {
#print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
- ERROR("OPEN_BRACE",
- "that open brace { should be on the previous line\n" .
- "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
+ if (ERROR("OPEN_BRACE",
+ "that open brace { should be on the previous line\n" .
+ "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n") &&
+ $fix &&
+ $rawlines[$ctx_ln - 2] =~ /^\+/ &&
+ $rawlines[$ctx_ln - 1] =~ /^\+\s*{\s*$/) {
+ $fixed[$ctx_ln - 2] = rtrim($fixed[$ctx_ln - 2]) . ' {';
+ fix_delete_line($ctx_ln - 1, $rawlines[$ctx_ln - 1]);
+ }
}
if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ &&
$ctx =~ /\)\s*\;\s*$/ &&
@@ -4807,8 +4813,15 @@ sub process {
$herectx .= raw_line($linenr, $n) . "\n";
}
- WARN("BRACES",
- "braces {} are not necessary for single statement blocks\n" . $herectx);
+ if (WARN("BRACES",
+ "braces {} are not necessary for single statement blocks\n" . $herectx) &&
+ $fix &&
+ $fixed[$fixlinenr] =~ /^\+.*\{\s*$/ &&
+ $fixed[$fixlinenr + 1] =~ /^\+.*;\s*$/ &&
+ $fixed[$fixlinenr + 2] =~ /^\+\s*\}\s*$/) {
+ $fixed[$fixlinenr] =~ s/\{\s*$//;
+ fix_delete_line($fixlinenr + 2, $rawlines[$fixlinenr + 2]);
+ }
}
}
--
1.8.3.1
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH] Add fix case for open braces Jeffrey Merkey <jeffmerkey@gmail.com> - 2016-02-16 02:30 +0100
csiph-web