mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@canonical.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>
Subject: [PATCH 4/6] checkpatch: if should not continue a preceeding brace
Date: Mon, 12 Jan 2009 12:45:02 +0000	[thread overview]
Message-ID: <1231764304-1491-5-git-send-email-apw@canonical.com> (raw)
In-Reply-To: <1231764304-1491-1-git-send-email-apw@canonical.com>

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


  parent reply	other threads:[~2009-01-12 12:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` [PATCH 3/6] checkpatch: allow parentheses on return handle array values Andy Whitcroft
2009-01-12 12:45 ` Andy Whitcroft [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1231764304-1491-5-git-send-email-apw@canonical.com \
    --to=apw@canonical.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®