[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN PATCH][for-4.19 v2 1/1] xen: introduce a deviation for Rule 11.9
On 16/10/2023 15:43, Jan Beulich wrote: On 11.10.2023 14:46, Nicola Vetrini wrote:--- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -109,13 +109,16 @@ #define offsetof(a,b) __builtin_offsetof(a,b)+/* Access the field of structure type, without defining a local variable */+#define access_field(type, member) (((type *)NULL)->member)This is not a field access, so I consider the macro misnamed. Question iswhether such a helper macro is needed in the first place.+#define typeof_field(type, member) typeof(access_field(type, member))If this needs adding, it wants to come .../** * sizeof_field(TYPE, MEMBER) * * @TYPE: The structure containing the field of interest * @MEMBER: The field to return the size of */ -#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) +#define sizeof_field(TYPE, MEMBER) sizeof(access_field(TYPE, MEMBER))... with a commend similar as this one has. (Or the commend could be slightly altered to cover both). I added access_field since it's possibly useful on its own in the future, but that may not be the case. Not a real field access, perhaps a fake_access_field? Ok about the missing comment for typeof_field. Further, if fiddling with these: Wouldn't they better move to macros.h? Jan That seems a good suggestion, as they are not compiler-specific. -- Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |