@samitouri / QOSamiQemu / commits / d6bb1d656c

scripts/checkpatch: remove check on forbidden space before '[' in C++

Lambdas are very confusing for checkpatch, so just relax this check. Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@mailo.com> Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-26-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>

Pierrick Bouvier committed Jun 15, 2026 at 12:35 UTC d6bb1d656cba9cf49210eab04671f2cfcfca8b66
1 file changed +2 -1
scripts/checkpatch.pl
+2 -1
@@ -2423,7 +2423,8 @@ sub process {
2423 # 3. inside a curly brace -- = { [0...10] = 5 }
2424 # 4. after a comma -- [1] = 5, [2] = 6
2425 # 5. in a macro definition -- #define abc(x) [x] = y
2426 - while ($line =~ /(.*?\s)\[/g) {
2426 + my $cpp = $realfile =~ /(\.cpp)$/;
2427 + while (!$cpp && $line =~ /(.*?\s)\[/g) {
2428 my ($where, $prefix) = ($-[1], $1);
2429 if ($prefix !~ /$Type\s+$/ &&
2430 ($where != 0 || $prefix !~ /^.\s+$/) &&