A common usage pattern for offsetof() is the following:

  offsetof(typeof(*ptr), member)

This is exactly the definition of struct_offset(). Some call sites use
offsetofend() instead of offsetof(). Add this variant, then replace all
call sites with the corresponding macros.

Signed-off-by: Bence Csokas <[email protected]>
---
Changes in v3:
- Add Coccinelle patch to tree instead of just the commit msg
- Fix Sashiko issues in prefix, commit msg and doc-comment
- Link to v2: 
https://patch.msgid.link/[email protected]

Changes in v2:
- Use struct_offset() instead of reinventing it
- Rename offsetofendp() to struct_offsetofend()
- Merge the two treewide patches
- Link to v1: 
https://patch.msgid.link/[email protected]

To: Kees Cook <[email protected]>
To: "Gustavo A. R. Silva" <[email protected]>
To: Marcel Holtmann <[email protected]>
To: Luiz Augusto von Dentz <[email protected]>
To: Sumit Semwal <[email protected]>
To: Christian König <[email protected]>
To: Philipp Stanner <[email protected]>
To: Sudeep Holla <[email protected]>
To: Cristian Marussi <[email protected]>
To: Maarten Lankhorst <[email protected]>
To: Maxime Ripard <[email protected]>
To: Thomas Zimmermann <[email protected]>
To: David Airlie <[email protected]>
To: Simona Vetter <[email protected]>
To: Jani Nikula <[email protected]>
To: Joonas Lahtinen <[email protected]>
To: Rodrigo Vivi <[email protected]>
To: Tvrtko Ursulin <[email protected]>
To: Lyude Paul <[email protected]>
To: Danilo Krummrich <[email protected]>
To: Zack Rusin <[email protected]>
To: Broadcom internal kernel review list <[email protected]>
To: Selvin Xavier <[email protected]>
To: Kalesh AP <[email protected]>
To: Jason Gunthorpe <[email protected]>
To: Leon Romanovsky <[email protected]>
To: Chengchang Tang <[email protected]>
To: Junxian Huang <[email protected]>
To: Laurent Pinchart <[email protected]>
To: Hans de Goede <[email protected]>
To: Mauro Carvalho Chehab <[email protected]>
To: Haiyang Zhang <[email protected]>
To: Wei Liu <[email protected]>
To: Dexuan Cui <[email protected]>
To: Andrew Lunn <[email protected]>
To: "David S. Miller" <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Miri Korenblit <[email protected]>
To: Jes Sorensen <[email protected]>
To: Ping-Ke Shih <[email protected]>
To: Johannes Berg <[email protected]>
To: Benson Leung <[email protected]>
To: Tzung-Bi Shih <[email protected]>
To: Guenter Roeck <[email protected]>
To: Nilesh Javali <[email protected]>
To: [email protected]
To: "James E.J. Bottomley" <[email protected]>
To: "Martin K. Petersen" <[email protected]>
To: Julia Lawall <[email protected]>
To: Nicolas Palix <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Bence Csokas (2):
      overflow: Add offsetofend() variant of struct_offset()
      treewide: Use struct_offset()

 drivers/bluetooth/btmrvl_main.c                    | 12 +++++-----
 drivers/dma-buf/dma-resv.c                         |  2 +-
 drivers/firmware/arm_scmi/base.c                   |  2 +-
 drivers/gpu/drm/drm_edid.c                         | 26 +++++++++++-----------
 drivers/gpu/drm/i915/gem/i915_gem_object.c         |  4 ++--
 drivers/gpu/drm/i915/i915_active.c                 |  2 +-
 drivers/gpu/drm/i915/i915_sw_fence_work.c          |  2 +-
 .../gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c  |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c            | 12 +++++-----
 drivers/infiniband/hw/bnxt_re/qplib_fp.c           |  2 +-
 drivers/infiniband/hw/hns/hns_roce_cq.c            |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_qp.c            |  6 ++---
 drivers/media/usb/uvc/uvc_v4l2.c                   |  4 ++--
 drivers/net/hyperv/rndis_filter.c                  |  2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c       |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c     |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c        |  2 +-
 .../net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c |  5 ++---
 drivers/net/wireless/realtek/rtl8xxxu/core.c       |  2 +-
 drivers/net/wireless/realtek/rtw88/fw.c            |  2 +-
 drivers/net/wireless/realtek/rtw89/core.c          |  2 +-
 drivers/net/wireless/realtek/rtw89/fw.c            |  8 +++----
 drivers/net/wireless/virtual/mac80211_hwsim_main.c |  4 ++--
 drivers/platform/chrome/cros_ec_lightbar.c         |  4 ++--
 drivers/scsi/qla2xxx/qla_gs.c                      |  2 +-
 drivers/scsi/qla2xxx/qla_mbx.c                     |  2 +-
 drivers/scsi/qla2xxx/qla_os.c                      |  2 +-
 drivers/scsi/qla2xxx/qla_tmpl.c                    |  4 ++--
 drivers/scsi/scsi_transport_fc.c                   |  2 +-
 include/linux/overflow.h                           | 12 ++++++++++
 scripts/coccinelle/api/struct_offsetof.cocci       | 14 ++++++++++++
 31 files changed, 89 insertions(+), 64 deletions(-)
---
base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
change-id: 20261105-offsetof-f62aa6348f0d

Best regards,
--  
Bence Csokas <[email protected]>


Reply via email to