HV: fix vmptable misc violations

Fix the violations list below:
1.Function should have one return entry.
2.Do not use -- or ++ operation.
3.For loop should be simple, shall not use comma operations.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Huihuang Shi 2019-07-05 13:39:30 +08:00 committed by ACRN System Integration
parent 564a60120a
commit 4b6dc0255f

View File

@ -65,18 +65,18 @@ static struct proc_entry proc_entry_template = {
.feature_flags = MPEP_FEATURES .feature_flags = MPEP_FEATURES
}; };
static uint8_t mpt_compute_checksum(void *base, size_t len) static uint8_t mpt_compute_checksum(const void *base, size_t len)
{ {
uint8_t *bytes; uint8_t sum = 0U;
uint8_t sum; size_t length;
size_t length = len; const uint8_t *bytes = base;
for (bytes = base, sum = 0U; length > 0U; length--) { for (length = len; length > 0U; length--) {
sum += *bytes; sum += *bytes;
bytes++; bytes++;
} }
return (256U - sum); return (~sum) + 1U;
} }
/** /**
@ -92,6 +92,7 @@ int32_t mptable_build(struct acrn_vm *vm)
size_t mptable_length; size_t mptable_length;
uint16_t i; uint16_t i;
uint16_t vcpu_num; uint16_t vcpu_num;
int32_t ret = 0;
uint64_t pcpu_bitmap = 0U; uint64_t pcpu_bitmap = 0U;
struct mptable_info *mptable; struct mptable_info *mptable;
struct acrn_vm_config *vm_config; struct acrn_vm_config *vm_config;
@ -110,10 +111,7 @@ int32_t mptable_build(struct acrn_vm *vm)
+ MPEII_NUM_LOCAL_IRQ * sizeof(struct int_entry); + MPEII_NUM_LOCAL_IRQ * sizeof(struct int_entry);
mptable_length = sizeof(struct mpfps) + mptable->mpch.base_table_length; mptable_length = sizeof(struct mpfps) + mptable->mpch.base_table_length;
if (mptable_length > MPTABLE_MAX_LENGTH) { if (mptable_length <= MPTABLE_MAX_LENGTH) {
return -1;
}
for (i = 0U; i < vcpu_num; i++) { for (i = 0U; i < vcpu_num; i++) {
uint16_t pcpu_id = ffs64(pcpu_bitmap); uint16_t pcpu_id = ffs64(pcpu_bitmap);
@ -139,6 +137,10 @@ int32_t mptable_build(struct acrn_vm *vm)
mpch = (struct mpcth *)curraddr; mpch = (struct mpcth *)curraddr;
mpch->checksum = mpt_compute_checksum(mpch, mpch->base_table_length); mpch->checksum = mpt_compute_checksum(mpch, mpch->base_table_length);
clac(); clac();
ret = 0;
return 0U; } else {
ret = -1;
}
return ret;
} }