Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] coccinelle: struct_offsetof.cocci lacks virtual mode
  declarations and guards
- [Low] coccinelle: struct_offsetof.cocci lacks tools/ and overflow.h
  exclusions
--

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

overflow: Add offsetofend() variant of struct_offset()

This commit adds a struct_offsetofend() helper macro to
include/linux/overflow.h and a Coccinelle semantic patch to convert
offsetof() and offsetofend() calls using typeof(*ptr).

> diff --git a/scripts/coccinelle/api/struct_offsetof.cocci 
> b/scripts/coccinelle/api/struct_offsetof.cocci
> new file mode 100644
> index 0000000000000..6cbc5596d673d
> --- /dev/null
> +++ b/scripts/coccinelle/api/struct_offsetof.cocci
> @@ -0,0 +1,14 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/// Use struct_offsetof() family of macros
> +///
> +// Confidence: High
> +@@
> +expression ptr, member;
> +@@
> +- offsetof(typeof(*ptr), member)
> ++ struct_offset(ptr, member)

[Severity: Low]
Does struct_offsetof.cocci need virtual mode declarations and mode guards
on its rules?

scripts/coccicheck checks each script for "virtual $MODE" before running
spatch, so without declarations such as "virtual patch", make coccicheck
skips this file with a warning in every mode.  When invoked directly with
COCCI=scripts/coccinelle/api/struct_offsetof.cocci, the unguarded patch
rules also produce no output in the default report mode and emit raw
replacement diffs in context mode.

> +@@
> +expression ptr, member;
> +@@
> +- offsetofend(typeof(*ptr), member)
> ++ struct_offsetofend(ptr, member)

[Severity: Low]
Will applying these rules across the tree break builds under tools/ or
rewrite the macro definitions in include/linux/overflow.h?

tools/include/linux/overflow.h does not define struct_offset() or
struct_offsetofend(), so converting matches in files such as
tools/perf/util/header.c and
tools/testing/selftests/bpf/progs/test_cls_redirect.c introduces calls to
undeclared macros unless tools/ and samples/ are excluded via rule
dependencies like other scripts in scripts/coccinelle/api/.  Running spatch
with --include-headers or on include/linux/overflow.h also rewrites the
struct_offset() and struct_offsetofend() definitions themselves into
recursive self-references.

In addition, matching typeof(*ptr) instead of typeof(*(ptr)) leaves
redundant parentheses on parenthesized expressions such as
offsetof(typeof(*(reg)), iobase_addr) in drivers/scsi/qla2xxx/qla_tmpl.c,
and the "///" header comment names a nonexistent struct_offsetof() macro.

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

Reply via email to