Re: [PATCH 05/10] HV: remove multiple return statement in get_vcpu_paging_mode() routine


Eddie Dong
 

Acked-by: Eddie Dong <eddie.dong@...>

-----Original Message-----
From: acrn-dev@...
[mailto:acrn-dev@...] On Behalf Of YanLiang
Sent: Friday, December 21, 2018 12:31 PM
To: acrn-dev@...
Cc: Guo, Chaohong <chaohong.guo@...>
Subject: [acrn-dev] [PATCH 05/10] HV: remove multiple return statement in
get_vcpu_paging_mode() routine

From: Chaohong guo <chaohong.guo@...>

To meet MISRA, remove multiple return in get_vcpu_paging_mode() routine.

Signed-off-by: Chaohong guo <chaohong.guo@...>
---
hypervisor/arch/x86/guest/guest.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/hypervisor/arch/x86/guest/guest.c
b/hypervisor/arch/x86/guest/guest.c
index 047f7d3d..48c2fcfc 100644
--- a/hypervisor/arch/x86/guest/guest.c
+++ b/hypervisor/arch/x86/guest/guest.c
@@ -47,23 +47,25 @@ uint64_t vcpumask2pcpumask(struct acrn_vm *vm,
uint64_t vdmask) enum vm_paging_mode get_vcpu_paging_mode(struct
acrn_vcpu *vcpu) {
enum vm_cpu_mode cpu_mode;
+ enum vm_paging_mode ret;

cpu_mode = get_vcpu_mode(vcpu);

if (cpu_mode == CPU_MODE_REAL) {
- return PAGING_MODE_0_LEVEL;
- }
- else if (cpu_mode == CPU_MODE_PROTECTED) {
- if (is_pae(vcpu)) {
- return PAGING_MODE_3_LEVEL;
- }
- else if (is_paging_enabled(vcpu)) {
- return PAGING_MODE_2_LEVEL;
- }
- return PAGING_MODE_0_LEVEL;
+ ret = PAGING_MODE_0_LEVEL;
+
+ } else if (cpu_mode == CPU_MODE_PROTECTED) {
+ if (is_pae(vcpu))
+ ret = PAGING_MODE_3_LEVEL;
+ else if (is_paging_enabled(vcpu))
+ ret = PAGING_MODE_2_LEVEL;
+ else
+ ret = PAGING_MODE_0_LEVEL;
} else { /* compatibility or 64bit mode */
- return PAGING_MODE_4_LEVEL;
+ ret = PAGING_MODE_4_LEVEL;
}
+
+ return ret;
}

/* TODO: Add code to check for Revserved bits, SMAP and PKE when do
translation
--
2.19.0


Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.