linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/17] Add memberof(), split some headers, and slightly simplify code
@ 2021-11-19 11:36 Alejandro Colomar
  2021-11-19 11:36 ` [PATCH 01/17] linux/container_of.h: Add memberof(T, m) Alejandro Colomar
                   ` (19 more replies)
  0 siblings, 20 replies; 86+ messages in thread
From: Alejandro Colomar @ 2021-11-19 11:36 UTC (permalink / raw)
  To: LKML
  Cc: Alejandro Colomar, Ajit Khaparde, Andrew Morton, Andy Shevchenko,
	Arnd Bergmann, Bjorn Andersson, Borislav Petkov, Corey Minyard,
	Chris Mason, Christian Brauner, David Sterba, Jani Nikula,
	Jason Wang, Jitendra Bhivare, John Hubbard, John S . Gruber,
	Jonathan Cameron, Joonas Lahtinen, Josef Bacik, Kees Cook,
	Ketan Mukadam, Len Brown, Michael S. Tsirkin, Miguel Ojeda,
	Mike Rapoport, Nick Desaulniers, Rafael J. Wysocki,
	Rasmus Villemoes, Rodrigo Vivi, Russell King, Somnath Kotur,
	Sriharsha Basavapatna, Subbu Seetharaman, intel-gfx, linux-acpi,
	linux-arm-kernel, linux-btrfs, linux-scsi, netdev,
	virtualization


Hi all,

I simplified some xxxof() macros,
by adding a new macro memberof(),
which implements a common operation in many of them.

I also splitted many of those macros into tiny headers,
since I noticed that touching those headers implied
recompiling almost the whole kernel.

Hopefully after this patch there will be less
things to recompile after touching one of those.

Having simpler headers means that now one can
include one of those without pulling too much stuff
that might break other stuff.

I removed some unnecessary casts too.

Every few commits in this series
and of course after the last commit
I rebuilt the kernel and run for a while with it without any problems.

Please note that I have written very few kernel code
and for example some files wouldn't let me include some of these files,
so I didn't change those.

What I mean is that,
even though this is super obvious and shouldn't break stuff,
and I'm not new to C,
I'm quite new to the kernel,
and ask that reviewers take deep look, please.


In the first and second commits
I changed a lot of stuff in many parts,
and that's why I CCd so many people (also in this cover letter).
However, to avoid spamming,
and since it would be a nightmare to
find all the relevant people affected in so many different areas,
I only CCd in 01, 02 and in the cover letter.
If anyone is interested in reading the full patch set,
I sent it to the LKML.


Thanks,
Alex


Alejandro Colomar (17):
  linux/container_of.h: Add memberof(T, m)
  Use memberof(T, m) instead of explicit NULL dereference
  Replace some uses of memberof() by its wrappers
  linux/memberof.h: Move memberof() to separate header
  linux/typeof_member.h: Move typeof_member() to a separate header
  Simplify sizeof(typeof_member()) to sizeof_field()
  linux/NULL.h: Move NULL to a separate header
  linux/offsetof.h: Move offsetof(T, m) to a separate header
  linux/offsetof.h: Implement offsetof() in terms of memberof()
  linux/container_of.h: Implement container_of_safe() in terms of
    container_of()
  linux/container_of.h: Cosmetic
  linux/container_of.h: Remove unnecessary cast to (void *)
  linux/sizeof_field.h: Move sizeof_field(T, m) to a separate header
  include/linux/: Include a smaller header if just for NULL
  linux/offsetofend.h: Move offsetofend(T, m) to a separate header
  linux/array_size.h: Move ARRAY_SIZE(arr) to a separate header
  include/: Include <linux/array_size.h> for ARRAY_SIZE()

 arch/x86/include/asm/bootparam_utils.h        |  3 +-
 arch/x86/kernel/signal_compat.c               |  5 ++--
 drivers/gpu/drm/i915/i915_sw_fence.c          |  1 +
 drivers/gpu/drm/i915/i915_utils.h             |  5 ++--
 drivers/gpu/drm/i915/intel_runtime_pm.h       |  3 +-
 drivers/net/ethernet/emulex/benet/be.h        | 10 +++----
 drivers/net/ethernet/i825xx/ether1.c          |  7 +++--
 drivers/platform/x86/wmi.c                    |  3 +-
 drivers/scsi/be2iscsi/be.h                    | 12 ++++----
 drivers/scsi/be2iscsi/be_cmds.h               |  5 +++-
 fs/btrfs/ctree.h                              |  5 ++--
 fs/proc/inode.c                               |  1 +
 include/acpi/actypes.h                        |  4 ++-
 include/crypto/internal/blake2b.h             |  1 +
 include/crypto/internal/blake2s.h             |  1 +
 include/crypto/internal/chacha.h              |  1 +
 include/drm/drm_mipi_dbi.h                    |  1 +
 include/drm/drm_mode_object.h                 |  1 +
 include/kunit/test.h                          |  1 +
 include/linux/NULL.h                          | 10 +++++++
 include/linux/arm_ffa.h                       |  1 +
 include/linux/array_size.h                    | 15 ++++++++++
 include/linux/blk_types.h                     |  1 +
 include/linux/can/core.h                      |  1 +
 include/linux/clk-provider.h                  |  1 +
 include/linux/container_of.h                  | 28 ++++++++++-------
 include/linux/counter.h                       |  1 +
 include/linux/crash_core.h                    |  1 +
 include/linux/efi.h                           |  1 +
 include/linux/extable.h                       |  2 +-
 include/linux/f2fs_fs.h                       |  1 +
 include/linux/filter.h                        |  3 ++
 include/linux/fs.h                            |  1 +
 include/linux/genl_magic_func.h               |  1 +
 include/linux/hashtable.h                     |  1 +
 include/linux/ieee80211.h                     |  1 +
 include/linux/kbuild.h                        |  3 ++
 include/linux/kernel.h                        |  7 +----
 include/linux/kfifo.h                         |  1 +
 include/linux/kvm_host.h                      |  3 ++
 include/linux/libata.h                        |  1 +
 include/linux/llist.h                         |  1 +
 include/linux/memberof.h                      | 11 +++++++
 include/linux/mlx5/device.h                   |  1 +
 include/linux/mlx5/driver.h                   |  1 +
 include/linux/mm_types.h                      |  1 +
 include/linux/moduleparam.h                   |  3 ++
 include/linux/mtd/rawnand.h                   |  1 +
 include/linux/netdevice.h                     |  1 +
 include/linux/netfilter.h                     |  1 +
 include/linux/nvme-fc.h                       |  2 ++
 include/linux/offsetof.h                      | 17 +++++++++++
 include/linux/offsetofend.h                   | 19 ++++++++++++
 include/linux/pagemap.h                       |  1 +
 include/linux/phy.h                           |  1 +
 include/linux/phy_led_triggers.h              |  1 +
 include/linux/pinctrl/machine.h               |  1 +
 include/linux/property.h                      |  1 +
 include/linux/rcupdate.h                      |  1 +
 include/linux/rcupdate_wait.h                 |  1 +
 include/linux/regmap.h                        |  1 +
 include/linux/sched/task.h                    |  1 +
 include/linux/sizeof_field.h                  | 14 +++++++++
 include/linux/skb_array.h                     |  1 +
 include/linux/skbuff.h                        |  1 +
 include/linux/skmsg.h                         |  3 ++
 include/linux/slab.h                          |  2 ++
 include/linux/spinlock_types.h                |  1 +
 include/linux/stddef.h                        | 30 +++----------------
 include/linux/string.h                        |  5 +++-
 include/linux/surface_aggregator/controller.h |  1 +
 include/linux/surface_aggregator/serial_hub.h |  1 +
 include/linux/swap.h                          |  1 +
 include/linux/ti-emif-sram.h                  |  1 +
 include/linux/typeof_member.h                 | 11 +++++++
 include/linux/ucs2_string.h                   |  2 +-
 include/linux/vdpa.h                          |  1 +
 include/linux/virtio_config.h                 | 17 ++++++-----
 include/linux/wireless.h                      |  2 ++
 include/net/bond_3ad.h                        |  1 +
 include/net/dsa.h                             |  1 +
 include/net/ip_vs.h                           |  1 +
 include/net/netfilter/nf_conntrack_tuple.h    |  1 +
 include/net/netfilter/nf_tables.h             |  1 +
 include/net/netlink.h                         |  1 +
 include/rdma/uverbs_ioctl.h                   |  1 +
 include/rdma/uverbs_named_ioctl.h             |  1 +
 include/scsi/scsi_host.h                      |  1 +
 include/sound/soc-dapm.h                      |  1 +
 include/sound/soc.h                           |  1 +
 include/trace/events/wbt.h                    |  1 +
 include/uapi/linux/netfilter/xt_sctp.h        |  1 +
 include/xen/hvm.h                             |  1 +
 kernel/kallsyms.c                             |  3 +-
 94 files changed, 255 insertions(+), 79 deletions(-)
 create mode 100644 include/linux/NULL.h
 create mode 100644 include/linux/array_size.h
 create mode 100644 include/linux/memberof.h
 create mode 100644 include/linux/offsetof.h
 create mode 100644 include/linux/offsetofend.h
 create mode 100644 include/linux/sizeof_field.h
 create mode 100644 include/linux/typeof_member.h

-- 
2.33.1


^ permalink raw reply	[flat|nested] 86+ messages in thread

end of thread, other threads:[~2021-11-23 18:07 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 11:36 [PATCH 00/17] Add memberof(), split some headers, and slightly simplify code Alejandro Colomar
2021-11-19 11:36 ` [PATCH 01/17] linux/container_of.h: Add memberof(T, m) Alejandro Colomar
2021-11-19 11:36 ` [PATCH 02/17] Use memberof(T, m) instead of explicit NULL dereference Alejandro Colomar
2021-11-23 18:07   ` Rafael J. Wysocki
2021-11-19 11:36 ` [PATCH 03/17] Replace some uses of memberof() by its wrappers Alejandro Colomar
2021-11-19 11:36 ` [PATCH 04/17] linux/memberof.h: Move memberof() to separate header Alejandro Colomar
2021-11-19 11:36 ` [PATCH 05/17] linux/typeof_member.h: Move typeof_member() to a " Alejandro Colomar
2021-11-19 11:36 ` [PATCH 06/17] Simplify sizeof(typeof_member()) to sizeof_field() Alejandro Colomar
2021-11-19 11:36 ` [PATCH 07/17] linux/NULL.h: Move NULL to a separate header Alejandro Colomar
2021-11-19 11:36 ` [PATCH 08/17] linux/offsetof.h: Move offsetof(T, m) " Alejandro Colomar
2021-11-19 11:36 ` [PATCH 09/17] linux/offsetof.h: Implement offsetof() in terms of memberof() Alejandro Colomar
2021-11-19 11:36 ` [PATCH 10/17] linux/container_of.h: Implement container_of_safe() in terms of container_of() Alejandro Colomar
2021-11-19 11:36 ` [PATCH 11/17] linux/container_of.h: Cosmetic Alejandro Colomar
2021-11-19 11:36 ` [PATCH 12/17] linux/container_of.h: Remove unnecessary cast to (void *) Alejandro Colomar
2021-11-19 11:36 ` [PATCH 13/17] linux/sizeof_field.h: Move sizeof_field(T, m) to a separate header Alejandro Colomar
2021-11-19 11:36 ` [PATCH 14/17] include/linux/: Include a smaller header if just for NULL Alejandro Colomar
2021-11-19 11:36 ` [PATCH 15/17] linux/offsetofend.h: Move offsetofend(T, m) to a separate header Alejandro Colomar
2021-11-19 11:36 ` [PATCH 16/17] linux/array_size.h: Move ARRAY_SIZE(arr) " Alejandro Colomar
2021-11-19 11:36 ` [PATCH 17/17] include/: Include <linux/array_size.h> for ARRAY_SIZE() Alejandro Colomar
2021-11-19 12:47 ` [PATCH 00/17] Add memberof(), split some headers, and slightly simplify code Jani Nikula
2021-11-19 13:16   ` Alejandro Colomar (man-pages)
2021-11-19 13:48     ` Jani Nikula
2021-11-19 14:54     ` Andy Shevchenko
2021-11-19 14:47 ` Arnd Bergmann
2021-11-19 15:06   ` Alejandro Colomar (man-pages)
2021-11-19 15:34     ` Andy Shevchenko
2021-11-19 15:38       ` Alejandro Colomar (man-pages)
2021-11-19 15:43         ` Alejandro Colomar (man-pages)
2021-11-19 15:49           ` Andy Shevchenko
2021-11-19 15:52             ` Alejandro Colomar (man-pages)
2021-11-19 16:07               ` Andy Shevchenko
2021-11-19 15:57     ` Arnd Bergmann
2021-11-19 16:10       ` Andy Shevchenko
2021-11-19 16:18         ` Arnd Bergmann
2021-11-19 16:22           ` Alejandro Colomar (man-pages)
2021-11-19 16:27             ` Arnd Bergmann
2021-11-19 16:35             ` Andy Shevchenko
2021-11-22 12:36               ` Jonathan Cameron
2021-11-19 16:12       ` Alejandro Colomar (man-pages)
2021-11-19 16:25         ` Arnd Bergmann
2021-11-19 16:37         ` Andy Shevchenko
2021-11-19 16:49           ` Alejandro Colomar (man-pages)
2021-11-20 13:00 ` [PATCH v2 00/20] Add memberof(), split headers, and " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 01/20] linux/stddef.h, linux/offsetof.h: Split offsetof() into a separate header Alejandro Colomar
2021-11-20 16:14     ` Andy Shevchenko
2021-11-20 16:22       ` Alejandro Colomar (man-pages)
2021-11-20 13:00   ` [PATCH v2 02/20] linux/stddef.h, linux/sizeof_field.h: Split sizeof_field() " Alejandro Colomar
2021-11-20 16:16     ` Andy Shevchenko
2021-11-20 13:00   ` [PATCH v2 03/20] linux/stddef.h, linux/offsetofend.h: Split offsetofend() " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 04/20] linux/stddef.h, linux/NULL.h: Split NULL " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 05/20] linux/container_of.h, linux/typeof_member.h: Split typeof_member() " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 06/20] linux/kernel.h, linux/array_size.h: Split ARRAY_SIZE() " Alejandro Colomar
2021-11-22  7:36     ` kernel test robot
2021-11-20 13:00   ` [PATCH v2 07/20] linux/memberof.h: Add memberof(T, m) macro Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 08/20] Implement container_of_safe() in terms of container_of() Alejandro Colomar
2021-11-21 13:31     ` Arnd Bergmann
2021-11-20 13:00   ` [PATCH v2 09/20] Implement offsetof(), sizeof_member(), typeof_member(), and container_of() in terms of memberof() Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 10/20] linux/container_of.h: Remove unnecessary cast Alejandro Colomar
2021-11-20 19:05     ` kernel test robot
2021-11-22 17:39     ` kernel test robot
2021-11-20 13:00   ` [PATCH v2 11/20] linux/container_of.h: Cosmetic Alejandro Colomar
2021-11-20 16:12     ` Andy Shevchenko
2021-11-20 16:33       ` Joe Perches
2021-11-20 16:44         ` Alejandro Colomar (man-pages)
2021-11-20 13:00   ` [PATCH v2 12/20] linux/must_be.h: Add must_be() to improve readability of BUILD_BUG_ON_ZERO() Alejandro Colomar
2021-11-20 15:05     ` Alexey Dobriyan
2021-11-20 15:22       ` Alejandro Colomar (man-pages)
2021-11-21 13:18       ` Arnd Bergmann
2021-11-20 13:00   ` [PATCH v2 13/20] Move BUILD_BUG_ON_ZERO to <linux/must_be.h> Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 13/20] linux/build_bug.h, linux/must_be.h: " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 14/20] linux/compiler_types.h, linux/same_type.h: Split __same_type() to a separate header Alejandro Colomar
2021-11-21 13:26     ` Arnd Bergmann
2021-11-20 13:00   ` [PATCH v2 15/20] linux/compiler.h: Implement __must_be_array() in terms of __must_be() Alejandro Colomar
2021-11-21 13:25     ` Arnd Bergmann
2021-11-20 13:01   ` [PATCH v2 16/20] linux/compiler.h, linux/array_size.h: Move __must_be_array() into <linux/array_size.h> Alejandro Colomar
2021-11-21 13:24     ` Arnd Bergmann
2021-11-22  8:51       ` Jani Nikula
2021-11-20 13:01   ` [PATCH v2 17/20] linux/array_size.h: Add __is_array(a) to help readability Alejandro Colomar
2021-11-21 13:22     ` Arnd Bergmann
2021-11-20 13:01   ` [PATCH v2 18/20] linux/power_of_2.h: Add __IS_POWER_OF_2(n) and __IS_POWER_OF_2_OR_0(n) macros Alejandro Colomar
2021-11-21 13:20     ` Arnd Bergmann
2021-11-22  8:55       ` Jani Nikula
2021-11-20 13:01   ` [PATCH v2 19/20] linux/build_bug.h, linux/power_of_2.h: Move [__]BUILD_BUG_ON_NOT_POWER_OF_2() to <linux/power_of_2.h> Alejandro Colomar
2021-11-20 13:01   ` [PATCH v2 20/20] linux/power_of_2.h: Implement [__]BUILD_BUG_ON_NOT_POWER_OF_2() in terms of __IS_POWER_OF_2[_OR_0]() Alejandro Colomar
2021-11-22 11:17   ` [PATCH v2 00/20] Add memberof(), split headers, and simplify code Andy Shevchenko
2021-11-22 12:07     ` Alejandro Colomar (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).