From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "Jan Beulich" <jbeulich@suse.com>,
xen-devel@lists.xenproject.org,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Teddy Astie" <teddy.astie@vates.tech>
Subject: Re: [PATCH] x86/shim: adjust for Misra C:2012 rule 20.12
Date: Wed, 13 May 2026 23:07:18 +0200 [thread overview]
Message-ID: <29550088408bfcfec43901c58e0f423f@bugseng.com> (raw)
In-Reply-To: <c82c5255-f2df-4822-b03a-c90ad3759e9a@citrix.com>
On 2026-05-13 18:30, Andrew Cooper wrote:
> On 13/05/2026 4:52 pm, Jan Beulich wrote:
>> ... ("A macro parameter used as an operand to the `#' or `##'
>> operators,
>> which is itself subject to further macro replacement, shall only be
>> used
>> as an operand to these operators"). Move the HVM_PARAM_ prefixes into
>> the
>> macro body, to use ## on the 2nd use (each) of the macro parameter.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> ---
>> I understand that this "absorbing" of prefixes isn't liked by some
>> people,
>> so I'm all ears towards alternative suggestions.
>>
>> https://gitlab.com/xen-project/hardware/xen-staging/-/jobs/14354119193
>> (also covering the 17.5 patch)
>
> Yeah, I'm a firm -1 to absorbing the prefixes. This is simple
> obfuscation just to hide it from Eclair's eyes.
>
> The ARM folks fixed this by using a SAF-6 annotation. e.g.
> 195d754170891
>
> Although honestly, the more I think about this, the more I think we
> should just globally deviate. I don't consider the concept having a
> well-named constant be used both as a value and a string a confusing
> thing.
>
There are already special cases for R20.12 also for things like
GENERATE_CASE
-doc_begin="The helper macro GENERATE_CASE may use a macro parameter for
ordinary
expansion and token pasting to improve readability. Only instances where
this
leads to a violation of the Rule are deviated."
-file_tag+={deliberate_generate_case, "^xen/arch/arm/vcpreg\\.c$"}
-config=MC3A2.R20.12,macros+={deliberate,
"name(GENERATE_CASE)&&loc(file(deliberate_generate_case))"}
-doc_end
which fits this macro perfectly. The more general question is whether we
want to whitelist certain macros uniformely, or in general Xen
developers want to use that pattern, because that conversation has two
very different outcomes: one is the disabling of the rule, though there
is an associated unspecified behaviour. Us.B 25 for C99 to be precise:
The order in which # and ## operations are evaluated during macro
substitution (6.10.3.2, 6.10.3.3). The other possible outcome is
deciding that the allowed cases, which should be very few (and indeed
they are currently) should use a single deviation pattern to be handled
uniformely.
--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
prev parent reply other threads:[~2026-05-13 21:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 15:52 [PATCH] x86/shim: adjust for Misra C:2012 rule 20.12 Jan Beulich
2026-05-13 16:30 ` Andrew Cooper
2026-05-13 21:07 ` 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=29550088408bfcfec43901c58e0f423f@bugseng.com \
--to=nicola.vetrini@bugseng.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.org \
/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.