|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/3] misra: add deviation of Rule 5.5
On 23.04.2025 01:43, victorm.lira@xxxxxxx wrote:
> From: Federico Serafini <federico.serafini@xxxxxxxxxxx>
>
> MISRA C Rule 5.5 states that:
> "Identifiers shall be distinct from macro names".
>
> A common pattern in Xen is to have a function-like macro that acts as a
> "wrapper" for the function to be called:
> before calling the function, the macro adds additional checks or
> increase/decrease the number of parameters depending on the
> configuration.
>
> Update ECLAIR configuration and deviations.rst.
>
> Signed-off-by: Federico Serafini <federico.serafini@xxxxxxxxxxx>
> Signed-off-by: Victor Lira <victorm.lira@xxxxxxx>
> ---
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> Cc: Michal Orzel <michal.orzel@xxxxxxx>
> Cc: Jan Beulich <jbeulich@xxxxxxxx>
> Cc: Julien Grall <julien@xxxxxxx>
> Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
> Cc: Federico Serafini <federico.serafini@xxxxxxxxxxx>
> Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> ---
> automation/eclair_analysis/ECLAIR/deviations.ecl | 8 ++++++++
> docs/misra/deviations.rst | 8 ++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl
> b/automation/eclair_analysis/ECLAIR/deviations.ecl
> index ffa23b53b7..303b06203a 100644
> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
> @@ -114,6 +114,14 @@ it defines would (in the common case) be already
> defined. Peer reviewed by the c
> -config=MC3A2.R5.5,reports+={deliberate,
> "any_area(decl(kind(function))||any_loc(macro(name(memcpy||memset||memmove))))&&any_area(any_loc(file(^xen/common/libelf/libelf-private\\.h$)))"}
> -doc_end
>
> +-doc_begin="Clashes between function-like macros and function names are
> +deliberate since a common pattern in Xen is to have a function-like macro
> +that acts as a \"wrapper\" for the function to be called:
> +before calling the function, the macro adds additional checks or
> +increase/decrease the number of parameters depending on the configuration."
> +-config=MC3A2.R5.5,reports+={deliberate,
> "all_area(macro(function_like())||decl(kind(function)))"}
> +-doc_end
> +
> -doc_begin="The type \"ret_t\" is deliberately defined multiple times,
> depending on the guest."
>
> -config=MC3A2.R5.6,reports+={deliberate,"any_area(any_loc(text(^.*ret_t.*$)))"}
> diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
> index d116aca7b9..a93ef1ff44 100644
> --- a/docs/misra/deviations.rst
> +++ b/docs/misra/deviations.rst
> @@ -130,6 +130,14 @@ Deviations related to MISRA C:2012 Rules:
> memmove.
> - Tagged as `deliberate` for ECLAIR.
>
> + * - R5.5
> + - Clashes between function-like macros and function names are
> + deliberate
They may or may not be deliberate, depending on context. I don't think it's a
good move to deviate this more widely than necessary. If I get the expression
above (in deviations.ecl) right, even
void func1(int);
void func2(int);
#define func1() func2(0)
#define func2() func1(0)
would be deviated, which I don't think we want. Especially when, in a less
contrived scenario, the clash may not easily be visible.
Jan
> since a common pattern in Xen is to have a function-like
> + macro that acts as a "wrapper" for the function to be called:
> + before calling the function, the macro adds additional checks or
> + increase/decrease the number of parameters depending on the
> configuration.
> + - Tagged as `deliberate` for ECLAIR.
> +
> * - R5.6
> - The type ret_t is deliberately defined multiple times depending on the
> type of guest to service.
> --
> 2.47.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |