Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bence Csokas" <bence.csokas@arm.com>
Cc: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	linux-rdma@vger.kernel.org, linux-hyperv@vger.kernel.org,
	linux-scsi@vger.kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v3 1/2] overflow: Add offsetofend() variant of struct_offset()
Date: Sat, 14 Nov 2026 16:09:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-214737@kernel.org> (raw)
In-Reply-To: <20261113-offsetof-v3-1-714df7053893@arm.com>

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 <bence.csokas@arm.com>

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/20261113-offsetof-v3-0-714df7053893@arm.com?part=1

  reply	other threads:[~2026-11-14 16:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 16:07 [PATCH v3 0/2] Add struct_offsetofend() for pointer arithmetic Bence Csokas
2026-11-13 16:07 ` [PATCH v3 1/2] overflow: Add offsetofend() variant of struct_offset() Bence Csokas
2026-11-14 16:09   ` sashiko-bot [this message]
2026-11-13 16:07 ` [PATCH v3 2/2] treewide: Use struct_offset() Bence Csokas
2026-11-13 17:50 ` ✓ i915.CI.BAT: success for Add struct_offsetofend() for pointer arithmetic (rev2) Patchwork
2026-11-14 18:21 ` ✗ i915.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-214737@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bence.csokas@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox