From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrjpJ-0004bl-QX for qemu-devel@nongnu.org; Thu, 29 Oct 2015 05:48:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrjpG-0003Ak-Uy for qemu-devel@nongnu.org; Thu, 29 Oct 2015 05:48:57 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:36290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrjpG-0003Ac-Ox for qemu-devel@nongnu.org; Thu, 29 Oct 2015 05:48:54 -0400 Received: by wmec75 with SMTP id c75so21427601wme.1 for ; Thu, 29 Oct 2015 02:48:54 -0700 (PDT) From: Leonid Bloch Date: Thu, 29 Oct 2015 11:48:38 +0200 Message-Id: <1446112118-12376-3-git-send-email-leonid@daynix.com> In-Reply-To: <1446112118-12376-1-git-send-email-leonid@daynix.com> References: <1446112118-12376-1-git-send-email-leonid@daynix.com> Subject: [Qemu-devel] [PATCH 2/2] 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: Blue Swirl Now, macro definition such as "#define abc(x) [x] = y" should pass without an error. Signed-off-by: Leonid Bloch --- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 455d94b..e7d9cce 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.4.3