Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] coccinelle: struct_offsetof.cocci requires parentheses around
  ptr
--

commit bd704e7223e04b0fb7bb740d9f758d180e12c2d8
Author: Bence Csokas <[email protected]>

overflow: Add offsetofend() variant of struct_offset()

This commit adds the struct_offsetofend() helper macro and a Coccinelle
semantic patch to convert offsetof(typeof(*ptr), member) and
offsetofend(typeof(*ptr), member) calls.

> diff --git a/scripts/coccinelle/api/struct_offsetof.cocci 
> b/scripts/coccinelle/api/struct_offsetof.cocci
> new file mode 100644
> index 0000000000000..5a30647d37872
> --- /dev/null
> +++ b/scripts/coccinelle/api/struct_offsetof.cocci
> @@ -0,0 +1,18 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/// Use struct_offset() family of macros
> +///
> +// Confidence: High
> +// Options: --no-includes --ignore ./tools/
> +
> +virtual patch
> +
> +@offsetof depends on patch@
> +expression ptr, member;
> +@@
> +- offsetof(typeof(*(ptr)), member)
> ++ struct_offset(ptr, member)
> +@offsetofend depends on patch@
> +expression ptr, member;
> +@@
> +- offsetofend(typeof(*(ptr)), member)
> ++ struct_offsetofend(ptr, member)

[Severity: Low]
Do the inner parentheses in typeof(*(ptr)) prevent these rules from
matching unparenthesized typeof(*ptr) call sites?

In Coccinelle, the paren isomorphism expands E to (E) in one direction,
so matching typeof(*(ptr)) requires explicit parentheses around ptr in
the C source.  Writing typeof(*ptr) matches both typeof(*ptr) and
typeof(*(ptr)).

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to