[PATCH] arm/ffa: deviate violation of MISRA C Rule 20.12

Dmytro Prokopchuk1 posted 1 patch 1 week, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/5c415313cb818323b70c59c2a9c26e6122bdc434.1773393963.git.dmytro._5Fprokopchuk1@epam.com
xen/arch/arm/tee/ffa.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] arm/ffa: deviate violation of MISRA C Rule 20.12
Posted by Dmytro Prokopchuk1 1 week, 3 days ago
MISRA C Rule 20.12 states: "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".

In this case the 'FFA_*' macros are used both as a regular macro argument and
as an operand for '#' stringification in the expansion of 'FW_ABI()'.
This is deviated using a SAF-x-safe comment.

No functional changes.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2383141997
---
 xen/arch/arm/tee/ffa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c
index aa43ae2595..d4a77206c6 100644
--- a/xen/arch/arm/tee/ffa.c
+++ b/xen/arch/arm/tee/ffa.c
@@ -80,6 +80,7 @@ struct ffa_fw_abi {
     const char *name;
 };
 
+/* SAF-6-safe Rule 20.12 expansion of macro FFA_* with FW_ABI */
 #define FW_ABI(abi) {abi,#abi}
 
 /* List of ABI we use from the firmware */
-- 
2.43.0
Re: [PATCH] arm/ffa: deviate violation of MISRA C Rule 20.12
Posted by Bertrand Marquis 1 week, 3 days ago
Hi Dmytro,

> On 13 Mar 2026, at 10:47, Dmytro Prokopchuk1 <dmytro_prokopchuk1@epam.com> wrote:
> 
> MISRA C Rule 20.12 states: "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".
> 
> In this case the 'FFA_*' macros are used both as a regular macro argument and
> as an operand for '#' stringification in the expansion of 'FW_ABI()'.
> This is deviated using a SAF-x-safe comment.
> 
> No functional changes.
> 
> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>

Thanks for that :-)

Looks good to me.

Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> Test CI pipeline:
> https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2383141997
> ---
> xen/arch/arm/tee/ffa.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c
> index aa43ae2595..d4a77206c6 100644
> --- a/xen/arch/arm/tee/ffa.c
> +++ b/xen/arch/arm/tee/ffa.c
> @@ -80,6 +80,7 @@ struct ffa_fw_abi {
>     const char *name;
> };
> 
> +/* SAF-6-safe Rule 20.12 expansion of macro FFA_* with FW_ABI */
> #define FW_ABI(abi) {abi,#abi}
> 
> /* List of ABI we use from the firmware */
> -- 
> 2.43.0