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 Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
xen-devel@lists.xenproject.org
Subject: Re: [XEN PATCH 6/6] x86: refactor macros in 'xen-mca.h' to address MISRA C:2012 Rule 5.3
Date: Mon, 07 Aug 2023 12:01:10 +0200 [thread overview]
Message-ID: <1f286a7219521052198c9cdadf400fda@bugseng.com> (raw)
In-Reply-To: <b575aad0-9c04-2037-b568-b2bc1fdc33d0@suse.com>
On 07/08/2023 10:31, Jan Beulich wrote:
> On 04.08.2023 17:27, Nicola Vetrini wrote:
>> The macros defined 'xen/include/public/arch-x86/xen-mca.h' have
>> needless
>> underscore prefixes for parameter names and variable names that cause
>> shadowing with e.g. the variable 'i' in function 'mce_action'.
>> Therefore, the renaming aims to resolve present shadowing issues and
>> lessen the probability of future ones.
>>
>> No functional change.
>>
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>
> I'm okay with the code adjustments here, but I'm afraid I don't follow
> the description: How is shadowing of "i" connected to the use of
> leading underscores in macro parameter names? I think you need to
> separate the two aspects in the wording.
>
The shadowing remark is tied to the second part of the sentence, but
I'll try
to make that clearer in v2.
>> --- a/xen/include/public/arch-x86/xen-mca.h
>> +++ b/xen/include/public/arch-x86/xen-mca.h
>> @@ -280,39 +280,39 @@ DEFINE_XEN_GUEST_HANDLE(xen_mc_logical_cpu_t);
>> /* Prototype:
>> * uint32_t x86_mcinfo_nentries(struct mc_info *mi);
>> */
>> -#define x86_mcinfo_nentries(_mi) \
>> - (_mi)->mi_nentries
>> +#define x86_mcinfo_nentries(mi) \
>> + (mi)->mi_nentries
>
> Isn't there another rule demanding parenthization of the whole
> construct? If so, adding the then-missing parentheses right here would
> be quite desirable. (Personally I'm happy about them not being there on
> suffix expressions, as kind of an exception to the general rule.)
>
If you're referring to Rule 20.7 then it does not require the whole
expression to be enclosed in
parentheses, as it's concerned with macro parameters (their full
expansion must parenthesize arguments at
some point, to prevent wrong evaluations due to operator precedence).
>> - if (_mi == NULL) break; \
>> - _mic = x86_mcinfo_first(_mi); \
>> - for (i = 0; i < x86_mcinfo_nentries(_mi); i++) { \
>> - if (_mic->type == (_type)) { \
>> - found = 1; \
>> + found_ = 0; \
>> + (ret) = NULL; \
>> + if (mi == NULL) break; \
>
> The lack of parentheses here definitely wants dealing with right away.
>
> Jan
Good catch
--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
prev parent reply other threads:[~2023-08-07 10:01 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 15:27 [XEN PATCH 0/6] xen: address MISRA C:2012 Rule 5.3 Nicola Vetrini
2023-08-04 15:27 ` [XEN PATCH 1/6] x86: rename variable 'e820' to " Nicola Vetrini
2023-08-04 21:19 ` Stefano Stabellini
2023-08-07 7:14 ` Nicola Vetrini
2023-08-07 8:09 ` Jan Beulich
2023-08-07 8:59 ` Nicola Vetrini
2023-08-07 9:10 ` Jan Beulich
2023-08-07 11:12 ` Nicola Vetrini
2023-08-07 12:02 ` Jan Beulich
2023-08-08 7:08 ` Nicola Vetrini
2023-08-08 7:21 ` Jan Beulich
2023-08-08 21:21 ` Stefano Stabellini
2023-08-08 21:24 ` Stefano Stabellini
2023-08-07 15:03 ` Nicola Vetrini
2023-08-07 15:07 ` Jan Beulich
2023-08-07 18:39 ` Stefano Stabellini
2023-08-04 15:27 ` [XEN PATCH 2/6] libelf: " Nicola Vetrini
2023-08-04 21:21 ` Stefano Stabellini
2023-08-07 8:11 ` Jan Beulich
2023-08-07 9:03 ` Nicola Vetrini
2023-08-04 15:27 ` [XEN PATCH 3/6] xen/delay: " Nicola Vetrini
2023-08-04 21:23 ` Stefano Stabellini
2023-08-07 8:14 ` Jan Beulich
2023-08-07 9:01 ` Julien Grall
2023-08-07 9:15 ` Jan Beulich
2023-08-07 9:23 ` Nicola Vetrini
2023-08-07 9:32 ` Jan Beulich
2023-08-07 9:33 ` Julien Grall
2023-08-04 15:27 ` [XEN PATCH 4/6] x86/include: " Nicola Vetrini
2023-08-04 21:24 ` Stefano Stabellini
2023-08-07 7:16 ` Nicola Vetrini
2023-08-04 15:27 ` [XEN PATCH 5/6] x86/xstate: " Nicola Vetrini
2023-08-04 21:26 ` Stefano Stabellini
2023-08-07 8:23 ` Jan Beulich
2023-08-07 9:20 ` Nicola Vetrini
2023-08-04 15:27 ` [XEN PATCH 6/6] x86: refactor macros in 'xen-mca.h' to " Nicola Vetrini
2023-08-04 15:38 ` Nicola Vetrini
2023-08-04 21:30 ` Stefano Stabellini
2023-08-07 8:31 ` Jan Beulich
2023-08-07 10:01 ` 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=1f286a7219521052198c9cdadf400fda@bugseng.com \
--to=nicola.vetrini@bugseng.com \
--cc=andrew.cooper3@citrix.com \
--cc=ayan.kumar.halder@amd.com \
--cc=consulting@bugseng.com \
--cc=jbeulich@suse.com \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.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.