Linux 5.4 Looks To Unify Way To Calculate The Size Of A Member Of A Struct
Written by Michael Larabel in Linux Kernel on 27 September 2019 at 07:30 AM EDT. 17 Comments
LINUX KERNEL --
It has surprisingly taken until the Linux 5.4 kernel in 2019 to potentially have a single unified way for calculating the size of a member of a struct within the kernel: Linux 5.4 is looking at adding a new sizeof_member macro for handling this purpose.

Up until now there's been three different ways to calculate the size of a member of a C struct with the existing macros of SIZEOF_FIELD, FIELD_SIZEOF, and sizeof_field... Well, with a proposed pull request that has been cleaned up now in Linux 5.4 with centralizing on a new macro called sizeof_member that the developers feel is more descriptive.

Longtime kernel developer Kees Cook submitted the tree-wide conversion for replacing those three former macros with this new sizeof_member() macro.

Linus Torvalds right now though appears uncertain whether to honor this pull request. His concerns are over the "sizeof_member" as opposed to "sizeof_field" considering the three macros set to be replaced were all based on the "size of field" labeling. To that point, other developers feels the "size of member" is more accurate terminology. The networking subsystem developers where most of these macros are also haven't commented on this proposal. Long story short, we'll see how the naming ends up but at least they look set on unifying the macro for calculating the size of a member in a struct.

About The Author
Author picture

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 10,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter or contacted via MichaelLarabel.com.

Related Linux Kernel News
Popular News This Week