From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753120AbdBTMQz (ORCPT ); Mon, 20 Feb 2017 07:16:55 -0500 Received: from narfation.org ([79.140.41.39]:54056 "EHLO v3-1039.vlinux.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752383AbdBTMQy (ORCPT ); Mon, 20 Feb 2017 07:16:54 -0500 Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org From: Sven Eckelmann To: Joe Perches Cc: Andy Whitcroft , linux-kernel@vger.kernel.org, Sven Eckelmann Subject: [PATCH] checkpatch: remove false unbalanced braces warning Date: Mon, 20 Feb 2017 13:16:44 +0100 Message-Id: <20170220121644.12209-1-sven@narfation.org> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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