Skip to contentSkip to conversation

docs/misra: add rule 2.1 exceptions

PATCH Superseded Stefano Stabellini 4 participants 6 messages Aug 23, 2023 – Sep 29, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 docs/misra: add rule 2.1 exceptions

From: Stefano Stabellini <[email protected]>

During the discussions that led to the acceptance of Rule 2.1, we decided on a few exceptions that were not properly recorded in rules.rst. Add them now.

---
Note that safe.json and the codebase are not yet updated with an appropriate tag for BUG, panic and friends.

v2:
- fix typo in commit message
- use "only referenced from assembly"
- use "Deliberate unreachability caused by"
- add "See safe.json"
- add acked-by (although I also added "See safe.json")

---
 docs/misra/rules.rst | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
docs/misra/rules.rst +12 -1
index 8f0e4d3f25..4f33ed4ba6 100644
@@ -106,7 +106,18 @@ maintainers if you want to suggest a change.
    * - `Rule 2.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_01_1.c>`_
      - Required
      - A project shall not contain unreachable code
-     -
+     - The following are allowed:
+         - Invariantly constant conditions, e.g. if(IS_ENABLED(CONFIG_HVM)) { S; }
+         - Switch with a controlling value statically determined not to
+           match one or more case statements
+         - Functions that are intended to be referenced only from
+           assembly code (e.g. 'do_trap_fiq')
+         - Deliberate unreachability caused by certain macros/functions,
+           e.g. BUG, assert_failed, panic, etc. See safe.json.
+         - asm-offsets.c, as they are not linked deliberately, because
+           they are used to generate definitions for asm modules
+         - Declarations without initializer are safe, as they are not
+           executed
 
    * - `Rule 2.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_06.c>`_
      - Advisory
Signature · 1 line
2.25.1
#1 lore raw
Quoted 11 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

During the discussions that led to the acceptance of Rule 2.1, we decided on a few exceptions that were not properly recorded in rules.rst. Add them now.

---
Note that safe.json and the codebase are not yet updated with an appropriate tag for BUG, panic and friends.

I think it should be updated with at least one of them. Otherwise...

Quoted 18 lines

v2:
- fix typo in commit message
- use "only referenced from assembly"
- use "Deliberate unreachability caused by"
- add "See safe.json"
- add acked-by (although I also added "See safe.json")

---
  docs/misra/rules.rst | 13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)
docs/misra/rules.rst +0 -0
index 8f0e4d3f25..4f33ed4ba6 100644
@@ -106,7 +106,18 @@ maintainers if you want to suggest a change.
     * - `Rule 2.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_01_1.c>`_
       - Required

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

Quoted 10 lines
docs/misra/rules.rst +8 -1
       - A project shall not contain unreachable code
-     -
+     - The following are allowed:
+         - Invariantly constant conditions, e.g. if(IS_ENABLED(CONFIG_HVM)) { S; }
+         - Switch with a controlling value statically determined not to
+           match one or more case statements
+         - Functions that are intended to be referenced only from
+           assembly code (e.g. 'do_trap_fiq')
+         - Deliberate unreachability caused by certain macros/functions,
+           e.g. BUG, assert_failed, panic, etc. See safe.json.

... someone reading this and then reading safe.json will wonder why none are present.

The list would then only contain the one(s) currently added in safe.json. But there should be no expectation that the examples will grow everytime one is added in safe.json.

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

Quoted 7 lines
docs/misra/rules.rst +4 -0
+         - asm-offsets.c, as they are not linked deliberately, because
+           they are used to generate definitions for asm modules
+         - Declarations without initializer are safe, as they are not
+           executed
 
     * - `Rule 2.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_06.c>`_
       - Advisory

Cheers,

Signature · 1 line
Julien Grall
#2 lore raw
Quoted 26 lines · Julien Grall
Quoted 14 lines · Stefano Stabellini

---
  docs/misra/rules.rst | 13 ++++++++++++-

  1 file changed, 12 insertions(+), 1 deletion(-)
docs/misra/rules.rst +0 -0
index 8f0e4d3f25..4f33ed4ba6 100644
@@ -106,7 +106,18 @@ maintainers if you want to suggest a change.
      * - `Rule 2.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_01_1.c>`_

       - Required
       - A project shall not contain unreachable code -     -
+     - The following are allowed:

Quoted 8 lines

+         - Invariantly constant conditions, e.g. if(IS_ENABLED(CONFIG_HVM)) { S; }
+         - Switch with a controlling value statically determined not to +           match one or more case statements
+         - Functions that are intended to be referenced only from +           assembly code (e.g. 'do_trap_fiq')
+         - Deliberate unreachability caused by certain macros/functions, +           e.g. BUG, assert_failed, panic, etc. See safe.json.

... someone reading this and then reading safe.json will wonder why none are present.

Quoted 1 line

The list would then only contain the one(s) currently added in safe.json. But there should be no expectation that the examples will grow everytime one is added in safe.json.

I forgot to mention that the rest of the exceptions look good to me. So if you prefer, if you could remove this exception and commit the rest.

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw
Quoted 29 lines · Julien Grall
Quoted 28 lines · Julien Grall
Quoted 15 lines · Stefano Stabellini

---
  docs/misra/rules.rst | 13 ++++++++++++-

  1 file changed, 12 insertions(+), 1 deletion(-)
docs/misra/rules.rst +0 -0
index 8f0e4d3f25..4f33ed4ba6 100644
@@ -106,7 +106,18 @@ maintainers if you want to suggest a change.
      * - `Rule 2.1

<https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_01_1.c>`_
       - Required
       - A project shall not contain unreachable code -     -
+     - The following are allowed:

Quoted 8 lines

+         - Invariantly constant conditions, e.g. if(IS_ENABLED(CONFIG_HVM)) { S; }
+         - Switch with a controlling value statically determined not to +           match one or more case statements
+         - Functions that are intended to be referenced only from +           assembly code (e.g. 'do_trap_fiq')
+         - Deliberate unreachability caused by certain macros/functions, +           e.g. BUG, assert_failed, panic, etc. See safe.json.

... someone reading this and then reading safe.json will wonder why none are present.

Quoted 6 lines
Quoted 3 lines

The list would then only contain the one(s) currently added in safe.json. But there should be no expectation that the examples will grow everytime one is added in safe.json.

I forgot to mention that the rest of the exceptions look good to me. So if you prefer, if you could remove this exception and commit the rest.

Let me see what I can do

Acked-by on v2 1/1
#4 lore raw
In reply to Stefano Stabellini

Hi Stefano,

Quoted 31 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

During the discussions that led to the acceptance of Rule 2.1, we decided on a few exceptions that were not properly recorded in rules.rst. Add them now.

---
Note that safe.json and the codebase are not yet updated with an appropriate tag for BUG, panic and friends.

v2:
- fix typo in commit message
- use "only referenced from assembly"
- use "Deliberate unreachability caused by"
- add "See safe.json"
- add acked-by (although I also added "See safe.json")
---
docs/misra/rules.rst | 13 ++++++++++++-

1 file changed, 12 insertions(+), 1 deletion(-)
docs/misra/rules.rst +0 -0
index 8f0e4d3f25..4f33ed4ba6 100644
@@ -106,7 +106,18 @@ maintainers if you want to suggest a change.
   * - `Rule 2.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_01_1.c>`_
     - Required

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

Quoted 10 lines
docs/misra/rules.rst +8 -1
     - A project shall not contain unreachable code
-     -
+     - The following are allowed:
+         - Invariantly constant conditions, e.g. if(IS_ENABLED(CONFIG_HVM)) { S; }
+         - Switch with a controlling value statically determined not to
+           match one or more case statements
+         - Functions that are intended to be referenced only from
+           assembly code (e.g. 'do_trap_fiq')
+         - Deliberate unreachability caused by certain macros/functions,
+           e.g. BUG, assert_failed, panic, etc. See safe.json.

As Julien requested, you should remove this.

With that handled:

Cheers
Bertrand

Quoted 10 lines
docs/misra/rules.rst +4 -0
+         - asm-offsets.c, as they are not linked deliberately, because
+           they are used to generate definitions for asm modules
+         - Declarations without initializer are safe, as they are not
+           executed
 
   * - `Rule 2.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_06.c>`_
     - Advisory
Signature · 1 line
2.25.1
#5 lore raw

Hi Stefano,

Quoted 48 lines · Bertrand Marquis

Hi Stefano,

Quoted 31 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

During the discussions that led to the acceptance of Rule 2.1, we decided on a few exceptions that were not properly recorded in rules.rst. Add them now.

---
Note that safe.json and the codebase are not yet updated with an appropriate tag for BUG, panic and friends.

v2:
- fix typo in commit message
- use "only referenced from assembly"
- use "Deliberate unreachability caused by"
- add "See safe.json"
- add acked-by (although I also added "See safe.json")
---
docs/misra/rules.rst | 13 ++++++++++++-

1 file changed, 12 insertions(+), 1 deletion(-)
docs/misra/rules.rst +0 -0
index 8f0e4d3f25..4f33ed4ba6 100644
@@ -106,7 +106,18 @@ maintainers if you want to suggest a change.
  * - `Rule 2.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_01_1.c>`_
    - Required

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

Quoted 10 lines
docs/misra/rules.rst +8 -1
    - A project shall not contain unreachable code
-     -
+     - The following are allowed:
+         - Invariantly constant conditions, e.g. if(IS_ENABLED(CONFIG_HVM)) { S; }
+         - Switch with a controlling value statically determined not to
+           match one or more case statements
+         - Functions that are intended to be referenced only from
+           assembly code (e.g. 'do_trap_fiq')
+         - Deliberate unreachability caused by certain macros/functions,
+           e.g. BUG, assert_failed, panic, etc. See safe.json.

As Julien requested, you should remove this.

Quoted 3 lines

With that handled:

With Bertrand’s comments addressed:

Kind regards,
Henry

Quoted 16 lines

Cheers
Bertrand

Quoted 10 lines
docs/misra/rules.rst +4 -0
+         - asm-offsets.c, as they are not linked deliberately, because
+           they are used to generate definitions for asm modules
+         - Declarations without initializer are safe, as they are not
+           executed
 
  * - `Rule 2.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_06.c>`_
    - Advisory
Signature · 1 line
2.25.1