Commit 22ff311a authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'sizeof_field-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull FIELD_SIZEOF conversion from Kees Cook:
 "A mostly mechanical treewide conversion from FIELD_SIZEOF() to
  sizeof_field(). This avoids the redundancy of having 2 macros
  (actually 3) doing the same thing, and consolidates on sizeof_field().
  While "field" is not an accurate name, it is the common name used in
  the kernel, and doesn't result in any unintended innuendo.

  As there are still users of FIELD_SIZEOF() in -next, I will clean up
  those during this coming development cycle and send the final old
  macro removal patch at that time"

* tag 'sizeof_field-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  treewide: Use sizeof_field() macro
  MIPS: OCTEON: Replace SIZEOF_FIELD() macro
parents 37d4e84f c593642c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -988,7 +988,7 @@ Similarly, if you need to calculate the size of some structure member, use

.. code-block:: c

	#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
	#define sizeof_field(t, f) (sizeof(((t*)0)->f))

There are also min() and max() macros that do strict type checking if you
need them.  Feel free to peruse that header file to see what else is already
+1 −1
Original line number Diff line number Diff line
@@ -1005,7 +1005,7 @@ struttura, usate

.. code-block:: c

	#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
	#define sizeof_field(t, f) (sizeof(((t*)0)->f))

Ci sono anche le macro min() e max() che, se vi serve, effettuano un controllo
rigido sui tipi.  Sentitevi liberi di leggere attentamente questo file
+1 −1
Original line number Diff line number Diff line
@@ -826,7 +826,7 @@ inline gcc 也可以自动使其内联。而且其他用户可能会要求移除

.. code-block:: c

	#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
	#define sizeof_field(t, f) (sizeof(((t*)0)->f))

还有可以做严格的类型检查的 min() 和 max() 宏,如果你需要可以使用它们。你可以
自己看看那个头文件里还定义了什么你可以拿来用的东西,如果有定义的话,你就不应
+3 −3
Original line number Diff line number Diff line
@@ -42,10 +42,10 @@ do { \

#define EXTRA_INFO(f) { \
		BUILD_BUG_ON_ZERO(offsetof(struct unwind_frame_info, f) \
				% FIELD_SIZEOF(struct unwind_frame_info, f)) \
				% sizeof_field(struct unwind_frame_info, f)) \
				+ offsetof(struct unwind_frame_info, f) \
				/ FIELD_SIZEOF(struct unwind_frame_info, f), \
				FIELD_SIZEOF(struct unwind_frame_info, f) \
				/ sizeof_field(struct unwind_frame_info, f), \
				sizeof_field(struct unwind_frame_info, f) \
	}
#define PTREGS_INFO(f) EXTRA_INFO(regs.f)

+1 −8
Original line number Diff line number Diff line
@@ -44,13 +44,6 @@ static struct cvmx_bootmem_desc *cvmx_bootmem_desc;

/* See header file for descriptions of functions */

/**
 * This macro returns the size of a member of a structure.
 * Logically it is the same as "sizeof(s::field)" in C++, but
 * C lacks the "::" operator.
 */
#define SIZEOF_FIELD(s, field) sizeof(((s *)NULL)->field)

/**
 * This macro returns a member of the
 * cvmx_bootmem_named_block_desc_t structure. These members can't
@@ -65,7 +58,7 @@ static struct cvmx_bootmem_desc *cvmx_bootmem_desc;
#define CVMX_BOOTMEM_NAMED_GET_FIELD(addr, field)			\
	__cvmx_bootmem_desc_get(addr,					\
		offsetof(struct cvmx_bootmem_named_block_desc, field),	\
		SIZEOF_FIELD(struct cvmx_bootmem_named_block_desc, field))
		sizeof_field(struct cvmx_bootmem_named_block_desc, field))

/**
 * This function is the implementation of the get macros defined
Loading