Skip to contentSkip to conversation

docs/misra: add Rule 7.4 and 9.4

PATCH In review Stefano Stabellini 3 participants 4 messages Jul 10, 2023 – Jul 11, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 docs/misra: add Rule 7.4 and 9.4

From: Stefano Stabellini <[email protected]>

Rule 9.4 is non-controversial and we have no violations.

Rule 7.4 is considered a good idea with the caveat that assigning a string literal to const void is allowed. I added a note to specify it.

---
Changes in v2:
- improve rule 7.4 note

---
 docs/misra/rules.rst | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
docs/misra/rules.rst +14 -0
index 622f35410c..67ee8c029e 100644
@@ -203,6 +203,15 @@ maintainers if you want to suggest a change.
      - The lowercase character l shall not be used in a literal suffix
      -
 
+   * - `Rule 7.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_07_04.c>`_
+     - Required
+     - A string literal shall not be assigned to an object unless the
+       objects type is pointer to const-qualified char
+     - All "character types" are permitted, as long as the string
+       element type and the character type match. (There should be no
+       casts.) Assigning a string literal to any object with type
+       "pointer to const-qualified void" is allowed.
+
    * - `Rule 8.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_01.c>`_
      - Required
      - Types shall be explicitly specified
@@ -275,6 +284,11 @@ maintainers if you want to suggest a change.
        braces
      -
 
+   * - `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
+     -
+
    * - `Rule 12.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_12_05.c>`_
      - Mandatory
      - The sizeof operator shall not have an operand which is a function
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#2 lore raw
In reply to Stefano Stabellini
Quoted 24 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

Rule 9.4 is non-controversial and we have no violations.

Rule 7.4 is considered a good idea with the caveat that assigning a string literal to const void is allowed. I added a note to specify it.

---
Changes in v2:
- improve rule 7.4 note
---
docs/misra/rules.rst | 14 ++++++++++++++

1 file changed, 14 insertions(+)
docs/misra/rules.rst +0 -0
index 622f35410c..67ee8c029e 100644

docs/misra/rules.rst maintainers if you want to suggest a change. · line 209

Quoted 7 lines
docs/misra/rules.rst +4 -0
@@ -203,6 +203,15 @@ maintainers if you want to suggest a change.
     - The lowercase character l shall not be used in a literal suffix
     -
 
+   * - `Rule 7.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_07_04.c>`_
+     - Required
+     - A string literal shall not be assigned to an object unless the
+       objects type is pointer to const-qualified char

NIT: Should it be s/objects/object/ ?

Quoted 24 lines
docs/misra/rules.rst +10 -0
+     - All "character types" are permitted, as long as the string
+       element type and the character type match. (There should be no
+       casts.) Assigning a string literal to any object with type
+       "pointer to const-qualified void" is allowed.
+
   * - `Rule 8.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_01.c>`_
     - Required
     - Types shall be explicitly specified
@@ -275,6 +284,11 @@ maintainers if you want to suggest a change.
       braces
     -
 
+   * - `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
+     -
+
   * - `Rule 12.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_12_05.c>`_
     - Mandatory
     - The sizeof operator shall not have an operand which is a function
Signature · 1 line
2.25.1

Apart from that, I’ve used the file with our script to import the rules and it worked.

#3 lore raw
Quoted 59 lines · Luca Fancellu
Quoted 22 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

Rule 9.4 is non-controversial and we have no violations.

Rule 7.4 is considered a good idea with the caveat that assigning a string literal to const void is allowed. I added a note to specify it.

---
Changes in v2:
- improve rule 7.4 note
---
docs/misra/rules.rst | 14 ++++++++++++++

1 file changed, 14 insertions(+)
docs/misra/rules.rst +0 -0
index 622f35410c..67ee8c029e 100644

docs/misra/rules.rst maintainers if you want to suggest a change. · line 209

Quoted 7 lines
docs/misra/rules.rst +4 -0
@@ -203,6 +203,15 @@ maintainers if you want to suggest a change.
     - The lowercase character l shall not be used in a literal suffix
     -
 
+   * - `Rule 7.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_07_04.c>`_
+     - Required
+     - A string literal shall not be assigned to an object unless the
+       objects type is pointer to const-qualified char

NIT: Should it be s/objects/object/ ?

Quoted 24 lines
docs/misra/rules.rst +10 -0
+     - All "character types" are permitted, as long as the string
+       element type and the character type match. (There should be no
+       casts.) Assigning a string literal to any object with type
+       "pointer to const-qualified void" is allowed.
+
   * - `Rule 8.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_01.c>`_
     - Required
     - Types shall be explicitly specified
@@ -275,6 +284,11 @@ maintainers if you want to suggest a change.
       braces
     -
 
+   * - `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
+     -
+
   * - `Rule 12.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_12_05.c>`_
     - Mandatory
     - The sizeof operator shall not have an operand which is a function
Signature · 1 line
2.25.1

Apart from that, I’ve used the file with our script to import the rules and it worked.

Quoted 1 line

Thanks! I fixed the typo on commit