All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: sstabellini@kernel.org, michal.orzel@amd.com,
	xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com,
	consulting@bugseng.com, andrew.cooper3@citrix.com,
	roger.pau@citrix.com,
	Simone Ballarin <simone.ballarin@bugseng.com>,
	Doug Goldstein <cardoe@cardoe.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [XEN PATCH][for-4.19 v2 1/1] xen: introduce a deviation for Rule 11.9
Date: Tue, 17 Oct 2023 10:16:56 +0200	[thread overview]
Message-ID: <c08559530413426ea7d06bc0921f2d85@bugseng.com> (raw)
In-Reply-To: <b2048df4-ec76-f91f-1f17-fcd45f295281@suse.com>

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)


      reply	other threads:[~2023-10-17  8:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 12:46 [XEN PATCH][for-4.19 v2 0/1] address violations of MISRA C:2012 Rule 11.9 Nicola Vetrini
2023-10-11 12:46 ` [XEN PATCH][for-4.19 v2 1/1] xen: introduce a deviation for " Nicola Vetrini
2023-10-11 16:56   ` andrew.cooper3
2023-10-12 12:27     ` Nicola Vetrini
2023-10-16 13:46     ` Jan Beulich
2023-10-12 23:24   ` Stefano Stabellini
2023-10-16 13:43   ` Jan Beulich
2023-10-16 16:49     ` Nicola Vetrini
2023-10-17  6:51       ` Jan Beulich
2023-10-17  8:16         ` Nicola Vetrini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c08559530413426ea7d06bc0921f2d85@bugseng.com \
    --to=nicola.vetrini@bugseng.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ayan.kumar.halder@amd.com \
    --cc=cardoe@cardoe.com \
    --cc=consulting@bugseng.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=simone.ballarin@bugseng.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xenia.ragiadakou@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.