Mailing List Archive

[xen staging] x86/hvm: address violations of MISRA C Rule 16.2
commit bbbbd024e8e5d5a286af51de883a33989a2031dc
Author: Nicola Vetrini <nicola.vetrini@bugseng.com>
AuthorDate: Fri Apr 5 11:14:34 2024 +0200
Commit: Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Apr 11 13:23:08 2024 +0100

x86/hvm: address violations of MISRA C Rule 16.2

Refactor the switch 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).

The switch clause ending with the pseudo
keyword "fallthrough" is an allowed exception to Rule 16.3.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
xen/arch/x86/hvm/hypercall.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
index eeb73e1aa5..14679dd829 100644
--- a/xen/arch/x86/hvm/hypercall.c
+++ b/xen/arch/x86/hvm/hypercall.c
@@ -119,12 +119,12 @@ int hvm_hypercall(struct cpu_user_regs *regs)
(mode == 8 ? regs->rdi : regs->ebx) == HVMOP_guest_request_vm_event )
break;

- if ( unlikely(hvm_get_cpl(curr)) )
- {
+ if ( likely(!hvm_get_cpl(curr)) )
+ break;
+ fallthrough;
default:
- regs->rax = -EPERM;
- return HVM_HCALL_completed;
- }
+ regs->rax = -EPERM;
+ return HVM_HCALL_completed;
case 0:
break;
}
--
generated by git-patchbot for /home/xen/git/xen.git#staging