diff mbox series

[XEN,v3,1/2] xen/domctl: address violations of MISRA C Rule 16.2

Message ID 6ebb49a8ae92dc036d7bed0c708a8830bb93c788.1713382466.git.nicola.vetrini@bugseng.com (mailing list archive)
State New
Headers show
Series address violations of MISRA C Rule 16.2 | expand

Commit Message

Nicola Vetrini April 17, 2024, 7:37 p.m. UTC
Refactor the first clauses so that a violation of
MISRA C Rule 16.2 is resolved (a switch label should be immediately
enclosed in the compound statement of the switch).
Note that the switch clause ending with the pseudo
keyword "fallthrough" is an allowed exception to Rule 16.3.

Convert fallthrough comments in other clauses to the pseudo-keyword
while at it.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 docs/misra/safe.json | 8 ++++++++
 xen/common/domain.c  | 1 +
 2 files changed, 9 insertions(+)

Comments

Jan Beulich April 18, 2024, 3:10 p.m. UTC | #1
On 17.04.2024 21:37, Nicola Vetrini wrote:
> Refactor the first clauses so that a violation of
> MISRA C Rule 16.2 is resolved (a switch label should be immediately
> enclosed in the compound statement of the switch).
> Note that the switch clause ending with the pseudo
> keyword "fallthrough" is an allowed exception to Rule 16.3.
> 
> Convert fallthrough comments in other clauses to the pseudo-keyword
> while at it.
> 
> No functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> Acked-by: Jan Beulich <jbeulich@suse.com>

I did ack a patch with this title, yes, but the content of that patch
was different. Besides all the references to the fallthrough pseudo-
keyword being unrelated to the change below, there's also nothing ...

> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -457,6 +457,7 @@ static int domain_teardown(struct domain *d)
>  
>          for_each_vcpu ( d, v )
>          {
> +            /* SAF-5-safe MISRA C Rule 16.2: switch label enclosed by for loop*/
>              PROGRESS_VCPU(teardown);
>  
>              rc = vcpu_teardown(v);

... domctl-ish in here. What is going on?

Jan
Nicola Vetrini April 18, 2024, 3:55 p.m. UTC | #2
On 2024-04-18 17:10, Jan Beulich wrote:
> On 17.04.2024 21:37, Nicola Vetrini wrote:
>> Refactor the first clauses so that a violation of
>> MISRA C Rule 16.2 is resolved (a switch label should be immediately
>> enclosed in the compound statement of the switch).
>> Note that the switch clause ending with the pseudo
>> keyword "fallthrough" is an allowed exception to Rule 16.3.
>> 
>> Convert fallthrough comments in other clauses to the pseudo-keyword
>> while at it.
>> 
>> No functional change.
>> 
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
> I did ack a patch with this title, yes, but the content of that patch
> was different. Besides all the references to the fallthrough pseudo-
> keyword being unrelated to the change below, there's also nothing ...
> 
>> --- a/xen/common/domain.c
>> +++ b/xen/common/domain.c
>> @@ -457,6 +457,7 @@ static int domain_teardown(struct domain *d)
>> 
>>          for_each_vcpu ( d, v )
>>          {
>> +            /* SAF-5-safe MISRA C Rule 16.2: switch label enclosed by 
>> for loop*/
>>              PROGRESS_VCPU(teardown);
>> 
>>              rc = vcpu_teardown(v);
> 
> ... domctl-ish in here. What is going on?
> 
> Jan

Oh, I must have edited the wrong patch when doing v3. Sorry about that.
The patch was this [1], just with the id changed.

[1] 
https://lore.kernel.org/xen-devel/2328b1a43f8bc4c9a9303c46f8eba2847c67a713.1712305581.git.nicola.vetrini@bugseng.com/
diff mbox series

Patch

diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index fe2bc185097d..9b13bcf71706 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -44,6 +44,14 @@ 
         },
         {
             "id": "SAF-5-safe",
+            "analyser": {
+                "eclair": "MC3R1.R16.2"
+            },
+            "name": "MC3R1.R16.2: using a case label when the most closely-enclosing compound statement is not a switch statement",
+            "text": "A switch label enclosed by some compound statement that is not the body of a switch is permitted within local helper macros that are unlikely to be misused or misunderstood."
+        },
+        {
+            "id": "SAF-6-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 282c3ab62308..1e555d658c97 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -457,6 +457,7 @@  static int domain_teardown(struct domain *d)
 
         for_each_vcpu ( d, v )
         {
+            /* SAF-5-safe MISRA C Rule 16.2: switch label enclosed by for loop*/
             PROGRESS_VCPU(teardown);
 
             rc = vcpu_teardown(v);