On 6/10/2026 11:07 PM, Manos Pitsidianakis wrote:
> On Wed, 03 Jun 2026 23:51, Pierrick Bouvier
> <[email protected]> wrote:
>> Lambdas are very confusing for checkpatch, so just relax this check.
>>
>> Signed-off-by: Pierrick Bouvier <[email protected]>
>> ---
> 
> cpp lambdas are confusing for a lot of people I guess
>

The concept are pretty close from what you'll see in Rust to be honest.
A data accessed by lambda can be either captured by:
- [&] or [&var] reference (hidden pointer to it)
- [=] or [var] copied
- [var=std::move(var)] moved in (similar to move)
- [] no capture, and address of lambda can be taken
You can also add a return type(`[]() -> T {`), but most of usages rely
on type deduction.

Of course, to the opposite of Rust, you're on your own to deal with
lifetime issues.

> Reviewed-by: Manos Pitsidianakis <[email protected]>
> 
>> scripts/checkpatch.pl | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index c74ec070c53..d90aca6fcbf 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+$/) &&
>> -- 
>> 2.43.0
>>
>>


Reply via email to