diff mbox

checkpatch: fix braces {} handling

Message ID 1314365677-10039-1-git-send-email-pavel.borzenkov@gmail.com
State New
Headers show

Commit Message

Pavel Borzenkov Aug. 26, 2011, 1:34 p.m. UTC
checkpatch.pl doesn't report warning for if/else statements with missing
'else' braces:

if (something) {
    foo;
} else
    bar;

The patch has been tested using the last 100 commits.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
---
 scripts/checkpatch.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Blue Swirl Aug. 27, 2011, 5:53 p.m. UTC | #1
Thanks, applied.

On Fri, Aug 26, 2011 at 1:34 PM, Pavel Borzenkov
<pavel.borzenkov@gmail.com> wrote:
> checkpatch.pl doesn't report warning for if/else statements with missing
> 'else' braces:
>
> if (something) {
>    foo;
> } else
>    bar;
>
> The patch has been tested using the last 100 commits.
>
> Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
> ---
>  scripts/checkpatch.pl |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 3498425..0eba357 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2532,7 +2532,7 @@ sub process {
>                                                $allowed = 1;
>                                        }
>                                }
> -                               if (!$seen) {
> +                               if ($seen != ($#chunks + 1)) {
>                                        WARN("braces {} are necessary for all arms of this statement\n" . $herectx);
>                                }
>                        }
> --
> 1.7.0.4
>
>
>
diff mbox

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3498425..0eba357 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2532,7 +2532,7 @@  sub process {
 						$allowed = 1;
 					}
 				}
-				if (!$seen) {
+				if ($seen != ($#chunks + 1)) {
 					WARN("braces {} are necessary for all arms of this statement\n" . $herectx);
 				}
 			}