Received: from eggs.gnu.org ([2001:4830:134:3::10]:42562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aViaU-00034R-17 for qemu-devel@nongnu.org; Tue, 16 Feb 2016 11:34:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aViaS-00075W-9L for qemu-devel@nongnu.org; Tue, 16 Feb 2016 11:34:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aViaS-00075G-3X for qemu-devel@nongnu.org; Tue, 16 Feb 2016 11:34:52 -0500 From: Paolo Bonzini Date: Tue, 16 Feb 2016 17:34:20 +0100 Message-Id: <1455640486-6101-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1455640486-6101-1-git-send-email-pbonzini@redhat.com> References: <1455640486-6101-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 02/28] checkpatch: Eliminate false positive in case of space before square bracket in a definition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Leonid Bloch From: Leonid Bloch Now, macro definition such as "#define abc(x) [x] = y" should pass without an error. Signed-off-by: Leonid Bloch Message-Id: <1446112118-12376-3-git-send-email-leonid@daynix.com> Signed-off-by: Paolo Bonzini --- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e71c3d1..c26f76e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1716,11 +1716,13 @@ sub process { # 2. at the beginning of a line for slice initialisers -- [0...10] = 5, # 3. inside a curly brace -- = { [0...10] = 5 } # 4. after a comma -- [1] = 5, [2] = 6 +# 5. in a macro definition -- #define abc(x) [x] = y while ($line =~ /(.*?\s)\[/g) { my ($where, $prefix) = ($-[1], $1); if ($prefix !~ /$Type\s+$/ && ($where != 0 || $prefix !~ /^.\s+$/) && $prefix !~ /{\s+$/ && + $prefix !~ /\#\s*define[^(]*\([^)]*\)\s+$/ && $prefix !~ /,\s+$/) { ERROR("space prohibited before open square bracket '['\n" . $herecurr); } -- 2.5.0