Skip to contentSkip to conversation

docs/misra: add 14.3

PATCH In review Stefano Stabellini 4 participants 6 messages Sep 8, 2023 – Sep 27, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 docs/misra: add 14.3

From: Stefano Stabellini <[email protected]>

Add 14.3, with project-wide deviations.

Also take the opportunity to clarify that parameters of function pointer types are expected to have names (Rule 8.2).

---
Changes in v3:
- add ,
- add switch(sizeof(...)) and switch(offsetof(...))

---
 docs/misra/rules.rst | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
docs/misra/rules.rst +14 -1
index 34916e266a..ac76e20a9c 100644
@@ -234,7 +234,8 @@ maintainers if you want to suggest a change.
    * - `Rule 8.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_02.c>`_
      - Required
      - Function types shall be in prototype form with named parameters
-     -
+     - Clarification: both function and function pointers types shall
+       have named parameters.
 
    * - `Rule 8.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_03.c>`_
      - Required
@@ -385,6 +386,18 @@ maintainers if you want to suggest a change.
      - A loop counter shall not have essentially floating type
      -
 
+   * - `Rule 14.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_03.c>`_
+     - Required
+     - Controlling expressions shall not be invariant
+     - Due to the extensive usage of IS_ENABLED, sizeof compile-time
+       checks, and other constructs that are detected as errors by MISRA
+       C scanners, managing the configuration of a MISRA C scanner for
+       this rule would be unmanageable. Thus, this rule is adopted with
+       a project-wide deviation on if, ?:, switch(sizeof(...)), and
+       switch(offsetof(...)) statements.
+
+       while(0) and while(1) and alike are allowed.
+
    * - `Rule 16.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_07.c>`_
      - Required
      - A switch-expression shall not have essentially Boolean type
Signature · 1 line
2.25.1
Acked-by on v3 1/1
#1 lore raw
Quoted 8 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

Add 14.3, with project-wide deviations.

Also take the opportunity to clarify that parameters of function pointer types are expected to have names (Rule 8.2).

I'm not overly happy with ...

Quoted 5 lines
docs/misra/rules.rst +1 -0
@@ -385,6 +386,18 @@ maintainers if you want to suggest a change.
      - A loop counter shall not have essentially floating type
      -
 
+   * - `Rule 14.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_03.c>`_

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

Quoted 10 lines
docs/misra/rules.rst +10 -0
+     - Required
+     - Controlling expressions shall not be invariant
+     - Due to the extensive usage of IS_ENABLED, sizeof compile-time
+       checks, and other constructs that are detected as errors by MISRA
+       C scanners, managing the configuration of a MISRA C scanner for
+       this rule would be unmanageable. Thus, this rule is adopted with
+       a project-wide deviation on if, ?:, switch(sizeof(...)), and
+       switch(offsetof(...)) statements.
+
+       while(0) and while(1) and alike are allowed.

... the final result, but seeing that you didn't get any ack in almost 3 weeks:

Jan

Acked-by on v3 1/1
#2 lore raw
In reply to Stefano Stabellini

Hi Stefano,

Quoted 10 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

Add 14.3, with project-wide deviations.

Also take the opportunity to clarify that parameters of function pointer types are expected to have names (Rule 8.2).

I am still not quite sure if we should accept a rule if we are deviating on so much cases but as we can revisit anyway:

Cheers
Bertrand

Quoted 44 lines

---
Changes in v3:
- add ,
- add switch(sizeof(...)) and switch(offsetof(...))
---
docs/misra/rules.rst | 15 ++++++++++++++-

1 file changed, 14 insertions(+), 1 deletion(-)
docs/misra/rules.rst +14 -1
index 34916e266a..ac76e20a9c 100644
@@ -234,7 +234,8 @@ maintainers if you want to suggest a change.
   * - `Rule 8.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_02.c>`_
     - Required
     - Function types shall be in prototype form with named parameters
-     -
+     - Clarification: both function and function pointers types shall
+       have named parameters.
 
   * - `Rule 8.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_03.c>`_
     - Required
@@ -385,6 +386,18 @@ maintainers if you want to suggest a change.
     - A loop counter shall not have essentially floating type
     -
 
+   * - `Rule 14.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_03.c>`_
+     - Required
+     - Controlling expressions shall not be invariant
+     - Due to the extensive usage of IS_ENABLED, sizeof compile-time
+       checks, and other constructs that are detected as errors by MISRA
+       C scanners, managing the configuration of a MISRA C scanner for
+       this rule would be unmanageable. Thus, this rule is adopted with
+       a project-wide deviation on if, ?:, switch(sizeof(...)), and
+       switch(offsetof(...)) statements.
+
+       while(0) and while(1) and alike are allowed.
+
   * - `Rule 16.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_07.c>`_
     - Required
     - A switch-expression shall not have essentially Boolean type
Signature · 1 line
2.25.1
#3 lore raw
In reply to Stefano Stabellini

Hi Henry,

This patch is now acked. Should it go in 4.18?

In terms of risk of breaking, it is zero as nothing builds or runs based on this document.

At the same time, the benefit is also low because the main value of this document is for future coding changes that would be too late now for 4.18. So the benefits of committing it now are ease of keeping track of the change and positive PR when we make the 4.18 release and we talk about the total number of MISRA C rules we adopted.

Quoted 52 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

Add 14.3, with project-wide deviations.

Also take the opportunity to clarify that parameters of function pointer types are expected to have names (Rule 8.2).

---
Changes in v3:
- add ,
- add switch(sizeof(...)) and switch(offsetof(...))

---
 docs/misra/rules.rst | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
docs/misra/rules.rst +14 -1
index 34916e266a..ac76e20a9c 100644
@@ -234,7 +234,8 @@ maintainers if you want to suggest a change.
    * - `Rule 8.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_02.c>`_
      - Required
      - Function types shall be in prototype form with named parameters
-     -
+     - Clarification: both function and function pointers types shall
+       have named parameters.
 
    * - `Rule 8.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_03.c>`_
      - Required
@@ -385,6 +386,18 @@ maintainers if you want to suggest a change.
      - A loop counter shall not have essentially floating type
      -
 
+   * - `Rule 14.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_03.c>`_
+     - Required
+     - Controlling expressions shall not be invariant
+     - Due to the extensive usage of IS_ENABLED, sizeof compile-time
+       checks, and other constructs that are detected as errors by MISRA
+       C scanners, managing the configuration of a MISRA C scanner for
+       this rule would be unmanageable. Thus, this rule is adopted with
+       a project-wide deviation on if, ?:, switch(sizeof(...)), and
+       switch(offsetof(...)) statements.
+
+       while(0) and while(1) and alike are allowed.
+
    * - `Rule 16.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_07.c>`_
      - Required
      - A switch-expression shall not have essentially Boolean type
Signature · 1 line
2.25.1
#4 lore raw

Actually adding Henry

Quoted 69 lines · Stefano Stabellini

Hi Henry,

This patch is now acked. Should it go in 4.18?

In terms of risk of breaking, it is zero as nothing builds or runs based on this document.

At the same time, the benefit is also low because the main value of this document is for future coding changes that would be too late now for 4.18. So the benefits of committing it now are ease of keeping track of the change and positive PR when we make the 4.18 release and we talk about the total number of MISRA C rules we adopted.

Quoted 52 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

Add 14.3, with project-wide deviations.

Also take the opportunity to clarify that parameters of function pointer types are expected to have names (Rule 8.2).

---
Changes in v3:
- add ,
- add switch(sizeof(...)) and switch(offsetof(...))

---
 docs/misra/rules.rst | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
docs/misra/rules.rst +14 -1
index 34916e266a..ac76e20a9c 100644
@@ -234,7 +234,8 @@ maintainers if you want to suggest a change.
    * - `Rule 8.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_02.c>`_
      - Required
      - Function types shall be in prototype form with named parameters
-     -
+     - Clarification: both function and function pointers types shall
+       have named parameters.
 
    * - `Rule 8.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_03.c>`_
      - Required
@@ -385,6 +386,18 @@ maintainers if you want to suggest a change.
      - A loop counter shall not have essentially floating type
      -
 
+   * - `Rule 14.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_03.c>`_
+     - Required
+     - Controlling expressions shall not be invariant
+     - Due to the extensive usage of IS_ENABLED, sizeof compile-time
+       checks, and other constructs that are detected as errors by MISRA
+       C scanners, managing the configuration of a MISRA C scanner for
+       this rule would be unmanageable. Thus, this rule is adopted with
+       a project-wide deviation on if, ?:, switch(sizeof(...)), and
+       switch(offsetof(...)) statements.
+
+       while(0) and while(1) and alike are allowed.
+
    * - `Rule 16.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_07.c>`_
      - Required
      - A switch-expression shall not have essentially Boolean type
Signature · 1 line
2.25.1
#5 lore raw

Hi Stefano,

Quoted 8 lines · Stefano Stabellini

Actually adding Henry

Quoted 3 lines · Stefano Stabellini

Hi Henry,

This patch is now acked. Should it go in 4.18?

Sure, a doc change should be harmless so:

Kind regards,
Henry

Quoted 66 lines
Quoted 66 lines

In terms of risk of breaking, it is zero as nothing builds or runs based on this document.

At the same time, the benefit is also low because the main value of this document is for future coding changes that would be too late now for 4.18. So the benefits of committing it now are ease of keeping track of the change and positive PR when we make the 4.18 release and we talk about the total number of MISRA C rules we adopted.

Quoted 52 lines · Stefano Stabellini

From: Stefano Stabellini <[email protected]>

Add 14.3, with project-wide deviations.

Also take the opportunity to clarify that parameters of function pointer types are expected to have names (Rule 8.2).

---
Changes in v3:
- add ,
- add switch(sizeof(...)) and switch(offsetof(...))
---
docs/misra/rules.rst | 15 ++++++++++++++-

1 file changed, 14 insertions(+), 1 deletion(-)
docs/misra/rules.rst +14 -1
index 34916e266a..ac76e20a9c 100644
@@ -234,7 +234,8 @@ maintainers if you want to suggest a change.
   * - `Rule 8.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_02.c>`_
     - Required
     - Function types shall be in prototype form with named parameters
-     -
+     - Clarification: both function and function pointers types shall
+       have named parameters.
 
   * - `Rule 8.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_03.c>`_
     - Required
@@ -385,6 +386,18 @@ maintainers if you want to suggest a change.
     - A loop counter shall not have essentially floating type
     -
 
+   * - `Rule 14.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_03.c>`_
+     - Required
+     - Controlling expressions shall not be invariant
+     - Due to the extensive usage of IS_ENABLED, sizeof compile-time
+       checks, and other constructs that are detected as errors by MISRA
+       C scanners, managing the configuration of a MISRA C scanner for
+       this rule would be unmanageable. Thus, this rule is adopted with
+       a project-wide deviation on if, ?:, switch(sizeof(...)), and
+       switch(offsetof(...)) statements.
+
+       while(0) and while(1) and alike are allowed.
+
   * - `Rule 16.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_07.c>`_
     - Required
     - A switch-expression shall not have essentially Boolean type
Signature · 1 line
2.25.1