[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 17/10/2023 08:51, Jan Beulich wrote:
On 16.10.2023 18:49, Nicola Vetrini wrote:
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
is
whether 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?

I don't like this either, I'm afraid: This isn't a fake access. Maybe
field_of() or field_of_type()? Yet at this point I'd still prefer for
this to not be a separate macro in the first place.

Jan

Ok, no problem.

--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.