Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1584569 > unrolled thread
| Started by | Sven Eckelmann <sven@narfation.org> |
|---|---|
| First post | 2017-02-20 13:20 +0100 |
| Last post | 2017-02-21 03:50 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] checkpatch: remove false unbalanced braces warning Sven Eckelmann <sven@narfation.org> - 2017-02-20 13:20 +0100
Re: [PATCH] checkpatch: remove false unbalanced braces warning Joe Perches <joe@perches.com> - 2017-02-21 03:50 +0100
| From | Sven Eckelmann <sven@narfation.org> |
|---|---|
| Date | 2017-02-20 13:20 +0100 |
| Subject | [PATCH] checkpatch: remove false unbalanced braces warning |
| Message-ID | <tcV6G-4y6-17@gated-at.bofh.it> |
Lines containing "} else {" should not be detected as unbalanced braces.
But the second check can be reduced to ".+else\s*{" and it therefore
never checked if the beginning of a line contains any other character
(like the relevant "}"). This check would also return true for
"} else {" and create warnings like
CHECK: Unbalanced braces around else statement
#391: FILE: ./net/batman-adv/tvlv.c:391:
+ } else {
The check can be changed to check the whole line for the missing "}" to
avoid this false positive.
Fixes: 0d1532456c26 ("checkpatch: notice unbalanced else braces in a patch")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ad5ea5c545b2..baa3c7be04ad 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5107,8 +5107,8 @@ sub process {
}
# check for single line unbalanced braces
- if ($sline =~ /.\s*\}\s*else\s*$/ ||
- $sline =~ /.\s*else\s*\{\s*$/) {
+ if ($sline =~ /^.\s*\}\s*else\s*$/ ||
+ $sline =~ /^.\s*else\s*\{\s*$/) {
CHK("BRACES", "Unbalanced braces around else statement\n" . $herecurr);
}
--
2.11.0
[toc] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2017-02-21 03:50 +0100 |
| Message-ID | <td8GB-4E6-7@gated-at.bofh.it> |
| In reply to | #1584569 |
On Mon, 2017-02-20 at 13:16 +0100, Sven Eckelmann wrote:
> Lines containing "} else {" should not be detected as unbalanced braces.
> But the second check can be reduced to ".+else\s*{" and it therefore
> never checked if the beginning of a line contains any other character
> (like the relevant "}"). This check would also return true for
> "} else {" and create warnings like
Yeah, thanks. That's what I meant to do originally.
Acked-by: Joe Perches <joe@perches.com>
cheers, Joe
> CHECK: Unbalanced braces around else statement
> #391: FILE: ./net/batman-adv/tvlv.c:391:
> + } else {
>
> The check can be changed to check the whole line for the missing "}" to
> avoid this false positive.
>
> Fixes: 0d1532456c26 ("checkpatch: notice unbalanced else braces in a patch")
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> scripts/checkpatch.pl | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index ad5ea5c545b2..baa3c7be04ad 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5107,8 +5107,8 @@ sub process {
> }
>
> # check for single line unbalanced braces
> - if ($sline =~ /.\s*\}\s*else\s*$/ ||
> - $sline =~ /.\s*else\s*\{\s*$/) {
> + if ($sline =~ /^.\s*\}\s*else\s*$/ ||
> + $sline =~ /^.\s*else\s*\{\s*$/) {
> CHK("BRACES", "Unbalanced braces around else statement\n" . $herecurr);
> }
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web