[PATCH] docs/misra: add Rule 9.3

Stefano Stabellini posted 1 patch 9 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20230711202145.2334563-1-sstabellini@kernel.org
docs/misra/rules.rst | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] docs/misra: add Rule 9.3
Posted by Stefano Stabellini 9 months, 3 weeks ago
From: Stefano Stabellini <stefano.stabellini@amd.com>

Specify that {} is allowed for zero-initialization.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
 docs/misra/rules.rst | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
index 72aa986bce..29a777938a 100644
--- a/docs/misra/rules.rst
+++ b/docs/misra/rules.rst
@@ -284,6 +284,11 @@ maintainers if you want to suggest a change.
        braces
      -
 
+   * - `Rule 9.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_03.c>`_
+     - Required
+     - Arrays shall not be partially initialized
+     - {} is also allowed to specify explicit zero-initialization
+
    * - `Rule 9.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_04.c>`_
      - Required
      - An element of an object shall not be initialized more than once
-- 
2.25.1
Re: [PATCH] docs/misra: add Rule 9.3
Posted by Luca Fancellu 9 months, 3 weeks ago

> On 11 Jul 2023, at 21:21, Stefano Stabellini <sstabellini@kernel.org> wrote:
> 
> From: Stefano Stabellini <stefano.stabellini@amd.com>
> 
> Specify that {} is allowed for zero-initialization.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>

Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>


> ---
> docs/misra/rules.rst | 5 +++++
> 1 file changed, 5 insertions(+)
> 
> diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
> index 72aa986bce..29a777938a 100644
> --- a/docs/misra/rules.rst
> +++ b/docs/misra/rules.rst
> @@ -284,6 +284,11 @@ maintainers if you want to suggest a change.
>        braces
>      -
> 
> +   * - `Rule 9.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_03.c>`_
> +     - Required
> +     - Arrays shall not be partially initialized
> +     - {} is also allowed to specify explicit zero-initialization

Not related to this patch, but how is the coding style for this? Is it {} without spaces or { } with one space?
It’s not specified in the coding style


> +
>    * - `Rule 9.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_04.c>`_
>      - Required
>      - An element of an object shall not be initialized more than once
> -- 
> 2.25.1
> 
> 

Re: [PATCH] docs/misra: add Rule 9.3
Posted by Jan Beulich 9 months, 3 weeks ago
On 12.07.2023 10:21, Luca Fancellu wrote:
>> On 11 Jul 2023, at 21:21, Stefano Stabellini <sstabellini@kernel.org> wrote:
>>
>> From: Stefano Stabellini <stefano.stabellini@amd.com>
>>
>> Specify that {} is allowed for zero-initialization.
>>
>> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> 
> Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

>> --- a/docs/misra/rules.rst
>> +++ b/docs/misra/rules.rst
>> @@ -284,6 +284,11 @@ maintainers if you want to suggest a change.
>>        braces
>>      -
>>
>> +   * - `Rule 9.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_03.c>`_
>> +     - Required
>> +     - Arrays shall not be partially initialized
>> +     - {} is also allowed to specify explicit zero-initialization
> 
> Not related to this patch, but how is the coding style for this? Is it {} without spaces or { } with one space?
> It’s not specified in the coding style

In the absence of anything written down, I'm inclined to infer both
forms are acceptable.

Jan

Re: [PATCH] docs/misra: add Rule 9.3
Posted by Luca Fancellu 9 months, 3 weeks ago

> On 12 Jul 2023, at 10:22, Jan Beulich <jbeulich@suse.com> wrote:
> 
> On 12.07.2023 10:21, Luca Fancellu wrote:
>>> On 11 Jul 2023, at 21:21, Stefano Stabellini <sstabellini@kernel.org> wrote:
>>> 
>>> From: Stefano Stabellini <stefano.stabellini@amd.com>
>>> 
>>> Specify that {} is allowed for zero-initialization.
>>> 
>>> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
>> 
>> Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
>>> --- a/docs/misra/rules.rst
>>> +++ b/docs/misra/rules.rst
>>> @@ -284,6 +284,11 @@ maintainers if you want to suggest a change.
>>>       braces
>>>     -
>>> 
>>> +   * - `Rule 9.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_03.c>`_
>>> +     - Required
>>> +     - Arrays shall not be partially initialized
>>> +     - {} is also allowed to specify explicit zero-initialization
>> 
>> Not related to this patch, but how is the coding style for this? Is it {} without spaces or { } with one space?
>> It’s not specified in the coding style
> 
> In the absence of anything written down, I'm inclined to infer both
> forms are acceptable.

:) I see, that’s what I was worried, anyway you are right! 
I have a WIP for clang format that would generate some discussion, but at least I hope it will clarify many of these small
things that make our codebase less uniform, making us write down some rules 

> 
> Jan