HV: remove few return statement in while loop of copy_gva function

The coding style of multiple returns/exit in while loop is not MISRA
compatible. Remove the returns in while loop.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Chaohong guo 2018-12-20 12:15:32 +08:00 committed by wenlingz
parent 5a583fb87c
commit b4b9ac593a

View File

@ -391,33 +391,29 @@ static inline int32_t copy_gva(struct acrn_vcpu *vcpu, void *h_ptr_arg, uint64_t
{ {
void *h_ptr = h_ptr_arg; void *h_ptr = h_ptr_arg;
uint64_t gpa = 0UL; uint64_t gpa = 0UL;
int32_t ret; int32_t ret = 0;
uint32_t len; uint32_t len;
uint64_t gva = gva_arg; uint64_t gva = gva_arg;
uint32_t size = size_arg; uint32_t size = size_arg;
while (size > 0U) { while ((size > 0U) && (ret == 0)) {
ret = gva2gpa(vcpu, gva, &gpa, err_code); ret = gva2gpa(vcpu, gva, &gpa, err_code);
if (ret < 0) { if (ret >= 0) {
*fault_addr = gva; len = local_copy_gpa(vcpu->vm, h_ptr, gpa, size, PAGE_SIZE_4K, cp_from_vm);
pr_err("error[%d] in GVA2GPA, err_code=0x%x", if (len != 0U) {
ret, *err_code);
return ret;
}
len = local_copy_gpa(vcpu->vm, h_ptr, gpa, size,
PAGE_SIZE_4K, cp_from_vm);
if (len == 0U) {
return -EINVAL;
}
gva += len; gva += len;
h_ptr += len; h_ptr += len;
size -= len; size -= len;
} else {
ret = -EINVAL;
}
} else {
*fault_addr = gva;
pr_err("error[%d] in GVA2GPA, err_code=0x%x", ret, *err_code);
}
} }
return 0; return ret;
} }
/* @pre Caller(Guest) should make sure gpa is continuous. /* @pre Caller(Guest) should make sure gpa is continuous.