diff mbox series

docs/misra: add R17.2 and R18.2

Message ID alpine.DEB.2.22.394.2409161559340.1417852@ubuntu-linux-20-04-desktop (mailing list archive)
State Superseded
Headers show
Series docs/misra: add R17.2 and R18.2 | expand

Commit Message

Stefano Stabellini Sept. 16, 2024, 11:02 p.m. UTC
The Xen community is already informally following both rules. Let's make
it explicit. Both rules have zero violations, only cautions. While we
want to go down to zero cautions in time, adding both rules to rules.rst
enables us to immediately make both rules gating in the ECLAIR job part
of gitlab-ci.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>

Comments

Bertrand Marquis Sept. 17, 2024, 6:13 a.m. UTC | #1
Hi Stefano,

> On 17 Sep 2024, at 01:02, Stefano Stabellini <sstabellini@kernel.org> wrote:
> 
> The Xen community is already informally following both rules. Let's make
> it explicit. Both rules have zero violations, only cautions. While we
> want to go down to zero cautions in time, adding both rules to rules.rst
> enables us to immediately make both rules gating in the ECLAIR job part
> of gitlab-ci.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> 
> diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
> index e99cb81089..9acd92cf78 100644
> --- a/docs/misra/rules.rst
> +++ b/docs/misra/rules.rst
> @@ -561,6 +561,12 @@ maintainers if you want to suggest a change.
>      - The features of <stdarg.h> shall not be used
>      -
> 
> +   * - `Rule 17.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_02.c>`_
> +     - Required
> +     - Functions shall not call themselves, either directly or indirectly
> +     - Limited forms of recursion are allowed if the recursion is bound
> +       (there is an upper limit and the upper limit is enforced)

NIT: . missing at the end.


Should we add a comment to say that the bounding needs to be explained in a comment or in a deviation ?

> +
>    * - `Rule 17.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_03.c>`_
>      - Mandatory
>      - A function shall not be declared implicitly
> @@ -593,6 +599,12 @@ maintainers if you want to suggest a change.
>        submitting new patches please try to decrease the number of
>        violations when possible.
> 
> +   * - `Rule 18.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_01.c>`_
> +     - Required
> +     - A pointer resulting from arithmetic on a pointer operand shall
> +       address an element of the same array as that pointer operand

NIT: . missing at the end.

More than that i do not find the sentence quite clear.
How about: Pointer arithmetic on an array should only address elements in the given array.

There might a better way to state that in english.
Or is this the "extract" from the misra rule directly ?


Cheers
Bertrand

> +     -
> +
>    * - `Rule 18.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_02.c>`_
>      - Required
>      - Subtraction between pointers shall only be applied to pointers
Nicola Vetrini Sept. 17, 2024, 6:32 a.m. UTC | #2
On 2024-09-17 08:13, Bertrand Marquis wrote:
> Hi Stefano,
> 
>> On 17 Sep 2024, at 01:02, Stefano Stabellini <sstabellini@kernel.org> 
>> wrote:
>> 
>> The Xen community is already informally following both rules. Let's 
>> make
>> it explicit. Both rules have zero violations, only cautions. While we
>> want to go down to zero cautions in time, adding both rules to 
>> rules.rst
>> enables us to immediately make both rules gating in the ECLAIR job 
>> part
>> of gitlab-ci.
>> 
>> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
>> 
>> diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
>> index e99cb81089..9acd92cf78 100644
>> --- a/docs/misra/rules.rst
>> +++ b/docs/misra/rules.rst
>> @@ -561,6 +561,12 @@ maintainers if you want to suggest a change.
>>      - The features of <stdarg.h> shall not be used
>>      -
>> 
>> +   * - `Rule 17.2 
>> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_02.c>`_
>> +     - Required
>> +     - Functions shall not call themselves, either directly or 
>> indirectly
>> +     - Limited forms of recursion are allowed if the recursion is 
>> bound
>> +       (there is an upper limit and the upper limit is enforced)
> 
> NIT: . missing at the end.
> 
> 
> Should we add a comment to say that the bounding needs to be explained 
> in a comment or in a deviation ?
> 
>> +
>>    * - `Rule 17.3 
>> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_03.c>`_
>>      - Mandatory
>>      - A function shall not be declared implicitly
>> @@ -593,6 +599,12 @@ maintainers if you want to suggest a change.
>>        submitting new patches please try to decrease the number of
>>        violations when possible.
>> 
>> +   * - `Rule 18.1 
>> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_01.c>`_
>> +     - Required
>> +     - A pointer resulting from arithmetic on a pointer operand shall
>> +       address an element of the same array as that pointer operand
> 
> NIT: . missing at the end.
> 
> More than that i do not find the sentence quite clear.
> How about: Pointer arithmetic on an array should only address elements 
> in the given array.
> 
> There might a better way to state that in english.
> Or is this the "extract" from the misra rule directly ?
> 

It is the full rule headline, similar to all other entries in the table.

> 
> Cheers
> Bertrand
> 
>> +     -
>> +
>>    * - `Rule 18.2 
>> <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_02.c>`_
>>      - Required
>>      - Subtraction between pointers shall only be applied to pointers
Stefano Stabellini Sept. 18, 2024, 8:21 p.m. UTC | #3
On Tue, 17 Sep 2024, Nicola Vetrini wrote:
> On 2024-09-17 08:13, Bertrand Marquis wrote:
> > Hi Stefano,
> > 
> > > On 17 Sep 2024, at 01:02, Stefano Stabellini <sstabellini@kernel.org>
> > > wrote:
> > > 
> > > The Xen community is already informally following both rules. Let's make
> > > it explicit. Both rules have zero violations, only cautions. While we
> > > want to go down to zero cautions in time, adding both rules to rules.rst
> > > enables us to immediately make both rules gating in the ECLAIR job part
> > > of gitlab-ci.
> > > 
> > > Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> > > 
> > > diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
> > > index e99cb81089..9acd92cf78 100644
> > > --- a/docs/misra/rules.rst
> > > +++ b/docs/misra/rules.rst
> > > @@ -561,6 +561,12 @@ maintainers if you want to suggest a change.
> > >      - The features of <stdarg.h> shall not be used
> > >      -
> > > 
> > > +   * - `Rule 17.2
> > > <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_02.c>`_
> > > +     - Required
> > > +     - Functions shall not call themselves, either directly or indirectly
> > > +     - Limited forms of recursion are allowed if the recursion is bound
> > > +       (there is an upper limit and the upper limit is enforced)
> > 
> > NIT: . missing at the end.
> > 
> > 
> > Should we add a comment to say that the bounding needs to be explained in a
> > comment or in a deviation ?

I added a note to that effect, I also added the '.'


> > > +
> > >    * - `Rule 17.3
> > > <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_03.c>`_
> > >      - Mandatory
> > >      - A function shall not be declared implicitly
> > > @@ -593,6 +599,12 @@ maintainers if you want to suggest a change.
> > >        submitting new patches please try to decrease the number of
> > >        violations when possible.
> > > 
> > > +   * - `Rule 18.1
> > > <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_01.c>`_
> > > +     - Required
> > > +     - A pointer resulting from arithmetic on a pointer operand shall
> > > +       address an element of the same array as that pointer operand
> > 
> > NIT: . missing at the end.
> > 
> > More than that i do not find the sentence quite clear.
> > How about: Pointer arithmetic on an array should only address elements in
> > the given array.
> > 
> > There might a better way to state that in english.
> > Or is this the "extract" from the misra rule directly ?
> > 
> 
> It is the full rule headline, similar to all other entries in the table.

As this is the rules title, it is best not to change it. Also we haven't
added '.' for the rules titles so far. I'll keep this as it is.
diff mbox series

Patch

diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
index e99cb81089..9acd92cf78 100644
--- a/docs/misra/rules.rst
+++ b/docs/misra/rules.rst
@@ -561,6 +561,12 @@  maintainers if you want to suggest a change.
      - The features of <stdarg.h> shall not be used
      -
 
+   * - `Rule 17.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_02.c>`_
+     - Required
+     - Functions shall not call themselves, either directly or indirectly
+     - Limited forms of recursion are allowed if the recursion is bound
+       (there is an upper limit and the upper limit is enforced)
+
    * - `Rule 17.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_03.c>`_
      - Mandatory
      - A function shall not be declared implicitly
@@ -593,6 +599,12 @@  maintainers if you want to suggest a change.
        submitting new patches please try to decrease the number of
        violations when possible.
 
+   * - `Rule 18.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_01.c>`_
+     - Required
+     - A pointer resulting from arithmetic on a pointer operand shall
+       address an element of the same array as that pointer operand
+     -
+
    * - `Rule 18.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_02.c>`_
      - Required
      - Subtraction between pointers shall only be applied to pointers