Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964981Ab3DJItj (ORCPT ); Wed, 10 Apr 2013 04:49:39 -0400 Received: from drsnuggles.stderr.nl ([94.142.244.14]:38464 "EHLO drsnuggles.stderr.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936347Ab3DJIt3 (ORCPT ); Wed, 10 Apr 2013 04:49:29 -0400 Date: Wed, 10 Apr 2013 10:49:27 +0200 From: Matthijs Kooijman To: Joe Perches , Andy Whitcroft Cc: linux-kernel@vger.kernel.org Subject: [PATCH] checkpatch: Only warn for empty lines before closing braces by themselves Message-ID: <20130410084927.GR13691@login.drsnuggles.stderr.nl> Mail-Followup-To: Matthijs Kooijman , Joe Perches , Andy Whitcroft , linux-kernel@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-PGP-Fingerprint: 7F6A 9F44 2820 18E2 18DE 24AA CF49 D0E6 8A2F AFBC X-PGP-Key: http://www.stderr.nl/static/files/gpg_pubkey.asc User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam-Score: -2.6 (--) X-Spam-Report: Spamchecked on "mail.drsnuggles.stderr.nl" pts rule name description ---- ---------------------- ------------------------------------------- -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.0 AWL AWL: From: address is in the auto white-list Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1767 Lines: 62 This check was intended to catch extra newlines at the end of a function definition, but it would trigger on any closing brace, including those of inline functions and macro definitions, triggering false positives. Now, only closing braces on a line by themselves trigger this check. Tested with: $ cat test.h /* test.h - Test file */ static inline int foo(void) { return 0; } static inline int bar(void) { return 1; } $ ./scripts/checkpatch.pl --strict -f test.h # Before this commit CHECK: Blank lines aren't necessary before a close brace '}' + +static inline int foo(void) { return 0; } CHECK: Blank lines aren't necessary before a close brace '}' + +} total: 0 errors, 0 warnings, 2 checks, 9 lines checked $ ./scripts/checkpatch.pl --strict -f test.h # After this commit CHECK: Blank lines aren't necessary before a close brace '}' + +} total: 0 errors, 0 warnings, 1 checks, 9 lines checked Signed-off-by: Matthijs Kooijman --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 532c41b..f962c30 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3236,7 +3236,7 @@ sub process { } # check for unnecessary blank lines around braces - if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) { + if (($line =~ /^.\s*}\s*$/ && $prevline =~ /^.\s*$/)) { CHK("BRACES", "Blank lines aren't necessary before a close brace '}'\n" . $hereprev); } -- 1.8.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/