diff mbox series

[XEN] docs/misra: Document ECLAIR extension to Rule 20.7

Message ID 77354513a986a14c37ec2dfc45cf3534b08b5e85.1736972547.git.nicola.vetrini@bugseng.com (mailing list archive)
State New
Headers show
Series [XEN] docs/misra: Document ECLAIR extension to Rule 20.7 | expand

Commit Message

Nicola Vetrini Jan. 16, 2025, 9:31 a.m. UTC
MISRA C Rule 20.7 states:
"Expressions resulting from the expansion of macro parameters shall
be enclosed in parentheses".

Document the behaviour of ECLAIR with respect to the CPP extension
that allows variable macro arguments to be named.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 docs/misra/rules.rst | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Jan Beulich Jan. 16, 2025, 9:51 a.m. UTC | #1
On 16.01.2025 10:31, Nicola Vetrini wrote:
> MISRA C Rule 20.7 states:
> "Expressions resulting from the expansion of macro parameters shall
> be enclosed in parentheses".
> 
> Document the behaviour of ECLAIR with respect to the CPP extension
> that allows variable macro arguments to be named.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> ---
>  docs/misra/rules.rst | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
> index e7763795b826..13890f6d8852 100644
> --- a/docs/misra/rules.rst
> +++ b/docs/misra/rules.rst
> @@ -671,7 +671,14 @@ maintainers if you want to suggest a change.
>         shall be enclosed in parentheses
>       - Extra parentheses are not required when macro parameters are used
>         as function arguments, as macro arguments, array indices, lhs in
> -       assignments or as initializers in initalizer lists.
> +       assignments or as initializers in initalizer lists. In addition,
> +       the use of a named variable argument in a macro that would constitute
> +       a violation of the rule is allowed by ECLAIR as an extension of the
> +       MISRA, since it may not always be possible to parenthesize such

Just one nit / question (addressable while committing, if desired): I
wouldn't have expected "the" before "MISRA". Is that conventional wording
in your environment?

Jan

> +       argument and the feature is non-standard::
> +
> +         #define M(args...) args
> +         #if M(1) + 0 
>  
>     * - `Rule 20.9 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_09.c>`_
>       - Required
Nicola Vetrini Jan. 16, 2025, 10:28 a.m. UTC | #2
On 2025-01-16 10:51, Jan Beulich wrote:
> On 16.01.2025 10:31, Nicola Vetrini wrote:
>> MISRA C Rule 20.7 states:
>> "Expressions resulting from the expansion of macro parameters shall
>> be enclosed in parentheses".
>> 
>> Document the behaviour of ECLAIR with respect to the CPP extension
>> that allows variable macro arguments to be named.
>> 
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>> ---
>>  docs/misra/rules.rst | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>> 
>> diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
>> index e7763795b826..13890f6d8852 100644
>> --- a/docs/misra/rules.rst
>> +++ b/docs/misra/rules.rst
>> @@ -671,7 +671,14 @@ maintainers if you want to suggest a change.
>>         shall be enclosed in parentheses
>>       - Extra parentheses are not required when macro parameters are 
>> used
>>         as function arguments, as macro arguments, array indices, lhs 
>> in
>> -       assignments or as initializers in initalizer lists.
>> +       assignments or as initializers in initalizer lists. In 
>> addition,
>> +       the use of a named variable argument in a macro that would 
>> constitute
>> +       a violation of the rule is allowed by ECLAIR as an extension 
>> of the
>> +       MISRA, since it may not always be possible to parenthesize 
>> such
> 
> Just one nit / question (addressable while committing, if desired): I
> wouldn't have expected "the" before "MISRA". Is that conventional 
> wording
> in your environment?
> 
> Jan

Hi Jan,

that was just a typo. It should have been "the MISRA guideline".
Thanks for catching that

> 
>> +       argument and the feature is non-standard::
>> +
>> +         #define M(args...) args
>> +         #if M(1) + 0
>> 
>>     * - `Rule 20.9 
>> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_09.c>`_
>>       - Required
Stefano Stabellini Jan. 16, 2025, 9:22 p.m. UTC | #3
On Thu, 16 Jan 2025, Nicola Vetrini wrote:
> On 2025-01-16 10:51, Jan Beulich wrote:
> > On 16.01.2025 10:31, Nicola Vetrini wrote:
> > > MISRA C Rule 20.7 states:
> > > "Expressions resulting from the expansion of macro parameters shall
> > > be enclosed in parentheses".
> > > 
> > > Document the behaviour of ECLAIR with respect to the CPP extension
> > > that allows variable macro arguments to be named.
> > > 
> > > Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> > > ---
> > >  docs/misra/rules.rst | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
> > > index e7763795b826..13890f6d8852 100644
> > > --- a/docs/misra/rules.rst
> > > +++ b/docs/misra/rules.rst
> > > @@ -671,7 +671,14 @@ maintainers if you want to suggest a change.
> > >         shall be enclosed in parentheses
> > >       - Extra parentheses are not required when macro parameters are used
> > >         as function arguments, as macro arguments, array indices, lhs in
> > > -       assignments or as initializers in initalizer lists.
> > > +       assignments or as initializers in initalizer lists. In addition,
> > > +       the use of a named variable argument in a macro that would
> > > constitute
> > > +       a violation of the rule is allowed by ECLAIR as an extension of
> > > the
> > > +       MISRA, since it may not always be possible to parenthesize such
> > 
> > Just one nit / question (addressable while committing, if desired): I
> > wouldn't have expected "the" before "MISRA". Is that conventional wording
> > in your environment?
> > 
> > Jan
> 
> Hi Jan,
> 
> that was just a typo. It should have been "the MISRA guideline".
> Thanks for catching that

With that fixed:

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
diff mbox series

Patch

diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
index e7763795b826..13890f6d8852 100644
--- a/docs/misra/rules.rst
+++ b/docs/misra/rules.rst
@@ -671,7 +671,14 @@  maintainers if you want to suggest a change.
        shall be enclosed in parentheses
      - Extra parentheses are not required when macro parameters are used
        as function arguments, as macro arguments, array indices, lhs in
-       assignments or as initializers in initalizer lists.
+       assignments or as initializers in initalizer lists. In addition,
+       the use of a named variable argument in a macro that would constitute
+       a violation of the rule is allowed by ECLAIR as an extension of the
+       MISRA, since it may not always be possible to parenthesize such
+       argument and the feature is non-standard::
+
+         #define M(args...) args
+         #if M(1) + 0 
 
    * - `Rule 20.9 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_09.c>`_
      - Required