@samitouri / QOSamiQemu / commits / 320de9f89f

scripts/checkpatch: ignore spaces required around some operators in C++

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. Some examples: ERROR: spaces required around that '&' (ctx:WxV) + auto &[counter, p] = *static_cast<TbData*>(udata); ^ ERROR: spaces required around that '*' (ctx:VxO) + auto &[counter, p] = *static_cast<TbData*>(udata); ^ ERROR: spaces required around that '>>' (ctx:VxW) + std::vector<std::pair<Vaddr, uint64_t>> v; ^ Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-25-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 320de9f89fbae08027ec0479b338cfc612e24c04
1 file changed +25
scripts/checkpatch.pl
+25
@@ -2621,6 +2621,31 @@ sub process {
2621 if ($op eq '::') {
2622 $ok = 1;
2623 }
2624 +
2625 + # Ignore * in C++: templates and
2626 + # pointer types are incorrectly
2627 + # flagged. Example:
2628 + # static_cast<T*>
2629 + if ($op eq '*') {
2630 + $ok = 1;
2631 + }
2632 +
2633 + # Ignore & in C++: & means a
2634 + # reference, and this create
2635 + # issues with some constructions.
2636 + # Example:
2637 + # auto &[first, second] = pair;
2638 + if ($op eq '&') {
2639 + $ok = 1;
2640 + }
2641 +
2642 + # Ignore >> in C++
2643 + # checkpatch is confused by
2644 + # >> closing templates. Example:
2645 + # vector<pair<A, B>>
2646 + if ($op eq '>>') {
2647 + $ok = 1;
2648 + }
2649 }
2650
2651 # Ignore email addresses <foo@bar>