Linux 5.4 Looks To Unify Way To Calculate The Size Of A Member Of A Struct
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.
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.
17 Comments