From d6bb1d656cba9cf49210eab04671f2cfcfca8b66 Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Mon, 15 Jun 2026 12:35:24 -0700 Subject: [PATCH] scripts/checkpatch: remove check on forbidden space before '[' in C++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lambdas are very confusing for checkpatch, so just relax this check. Reviewed-by: Chao Liu Reviewed-by: Manos Pitsidianakis Reviewed-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-26-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 538e059e26..03f35e7501 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2423,7 +2423,8 @@ sub process { # 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 $cpp = $realfile =~ /(\.cpp)$/; + while (!$cpp && $line =~ /(.*?\s)\[/g) { my ($where, $prefix) = ($-[1], $1); if ($prefix !~ /$Type\s+$/ && ($where != 0 || $prefix !~ /^.\s+$/) &&