|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN PATCH 4/6] x86emul: address violations of MISRA C Rule 20.7
On 11.06.2024 17:53, Nicola Vetrini wrote:
> MISRA C Rule 20.7 states: "Expressions resulting from the expansion
> of macro parameters shall be enclosed in parentheses". Therefore, some
> macro definitions should gain additional parentheses to ensure that all
> current and future users will be safe with respect to expansions that
> can possibly alter the semantics of the passed-in macro parameter.
>
> No functional change.
>
> Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
> ---
> These local helpers could in principle be deviated, but the readability
> and functionality are essentially unchanged by complying with the rule,
> so I decided to modify the macro definition as the preferred option.
Well, yes, but ...
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -2255,7 +2255,7 @@ x86_emulate(
> switch ( modrm_reg & 7 )
> {
> #define GRP2(name, ext) \
> - case ext: \
> + case (ext): \
> if ( ops->rmw && dst.type == OP_MEM ) \
> state->rmw = rmw_##name; \
> else \
> @@ -8611,7 +8611,7 @@ int x86_emul_rmw(
> unsigned long dummy;
>
> #define XADD(sz, cst, mod) \
> - case sz: \
> + case (sz): \
> asm ( "" \
> COND_LOCK(xadd) " %"#mod"[reg], %[mem]; " \
> _POST_EFLAGS("[efl]", "[msk]", "[tmp]") \
... this is really nitpicky of the rule / tool. What halfway realistic
ways do you see to actually misuse these macros? What follows the "case"
keyword is just an expression; no precedence related issues are possible.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |