On 6/8/2026 2:21 AM, Peter Maydell wrote:
> On Wed, 3 Jun 2026 at 21:55, Pierrick Bouvier
> <[email protected]> wrote:
>>
>> C++ has a different style when it comes to space around references,
>> dereferences, so don't report it.
>> Also, closing templates with >> gets wrongly confused with >> operator,
>> so just relax this check.
>>
>> Signed-off-by: Pierrick Bouvier <[email protected]>
>> ---
>> scripts/checkpatch.pl | 17 +++++++++++++++++
>> 1 file changed, 17 insertions(+)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index 2189db19f54..c74ec070c53 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -2621,6 +2621,23 @@ sub process {
>> if ($op eq '::') {
>> $ok = 1;
>> }
>> +
>> + # Ignore * in C++
>> + if ($op eq '*') {
>> + $ok = 1;
>> + }
>> +
>> + # Ignore & in C++
>
> I think it would be helpful if these comments said why we're ignoring
> the operators, the way we do for the one about ">>". Why we should
> ignore "::" is clear (it's an operator that exists in C++ and not C),
> but * and & are both present in C, so we should say why C++ is special.
>
I'll add it thanks.
For reference, that's (some of) the errors I ran into that motivated
this change:
ERROR: spaces required around that '&' (ctx:WxV)
#58: FILE: contrib/plugins/cpp.cpp:392:
+ auto &[counter, p] = *static_cast<TbData*>(udata);
^
ERROR: spaces required around that '*' (ctx:VxO)
#58: FILE: contrib/plugins/cpp.cpp:392:
+ auto &[counter, p] = *static_cast<TbData*>(udata);
^
ERROR: spaces required around that '>>' (ctx:VxW)
#67: FILE: contrib/plugins/cpp.cpp:401:
+ std::vector<std::pair<Vaddr, uint64_t>> v;
^
>> + if ($op eq '&') {
>> + $ok = 1;
>> + }
>> +
>> + # Ignore >> in C++
>> + # checkpatch is confused by
>> + # >> closing templates
>> + if ($op eq '>>') {
>> + $ok = 1;
>> + }
>> }
>
> thanks
> -- PMM