Linux Security Modules development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bence Csokas" <bence.csokas@arm.com>
Cc: linux-rdma@vger.kernel.org, bpf@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	linux-hyperv@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-sound@vger.kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH 1/3] stddef: Add offsetofp() and offsetofendp() for pointer arithmetic
Date: Thu, 05 Nov 2026 17:25:50 +0000	[thread overview]
Message-ID: <sashiko-outbox-199612@kernel.org> (raw)
In-Reply-To: <20261105-offsetof-v1-1-4153f5c10edc@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] stddef: offsetofp() duplicates existing struct_offset() macro
--

commit 1381df6311c78f1d5db9e362d720874ccb5bad75
Author: Bence Csokas <bence.csokas@arm.com>

stddef: Add offsetofp() and offsetofendp() for pointer arithmetic

This commit introduces offsetofp() and offsetofendp() in
include/linux/stddef.h as convenience wrappers around offsetof() and
offsetofend() that take a struct pointer instead of a struct type.

> diff --git a/include/linux/stddef.h b/include/linux/stddef.h
> index e1851c50c89b5..87f0e131d2350 100644
> --- a/include/linux/stddef.h
> +++ b/include/linux/stddef.h
> @@ -32,6 +32,22 @@ enum {
>  #define offsetofend(TYPE, MEMBER) \
>  	(offsetof(TYPE, MEMBER)	+ sizeof_field(TYPE, MEMBER))
>  
> +/**
> + * offsetofp() - Get the offset of a struct field from a pointer to the struct
> + *
> + * @P: Pointer to the structure
> + * @MEMBER: The member within the structure to get the start offset of
> + */
> +#define offsetofp(P, MEMBER) offsetof(typeof(*(P)), MEMBER)
> +
> +/**
> + * offsetofendp() - Get the end of a struct field from a pointer to the struct
> + *
> + * @P: Pointer to the structure
> + * @MEMBER: The member within the structure to get the end offset of
> + */
> +#define offsetofendp(P, MEMBER) offsetofend(typeof(*(P)), MEMBER)

[Severity: Low]
This isn't a bug, but commit f6ed9c5d3190 ("overflow: Implement
size_t saturating arithmetic helpers") already added struct_offset() in
include/linux/overflow.h with the same definition:

    #define struct_offset(p, member) (offsetof(typeof(*(p)), member))

which is currently used in kernel/trace/trace.c and
sound/soc/codecs/cs-amp-lib.c, following the struct_size(p, member, count)
vs struct_size_t(type, member, count) naming convention.

Should offsetofp() and struct_offset() be consolidated (and offsetofendp()
aligned with the chosen naming convention) so there aren't two redundant
macros for pointer-based member offsets across the tree?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-offsetof-v1-0-4153f5c10edc@arm.com?part=1

  reply	other threads:[~2026-11-05 17:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 17:16 [PATCH 0/3] Add offsetofp() and offsetofendp() for pointer arithmetic Bence Csokas
2026-11-05 17:16 ` [PATCH 1/3] stddef: " Bence Csokas
2026-11-05 17:25   ` sashiko-bot [this message]
2026-11-05 17:16 ` [PATCH 2/3] treewide: Use offsetofendp() Bence Csokas
2026-11-05 17:16 ` [PATCH 3/3] treewide: Use offsetofp() Bence Csokas

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-199612@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bence.csokas@arm.com \
    --cc=bpf@vger.kernel.org \
    --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=linux-security-module@vger.kernel.org \
    --cc=linux-sound@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