From 79d033027b4c739cff9d77a8a6e01f1b523f5a56 Mon Sep 17 00:00:00 2001 From: Huihuang Shi Date: Tue, 9 Jul 2019 11:19:55 +0800 Subject: [PATCH] HV: fix vmptable "Casting operation to a pointer" ACRN Coding guidelines requires two different types pointer can't convert to each other, except void *. Tracked-On: #861 Signed-off-by: Huihuang Shi --- hypervisor/arch/x86/configs/vmptable.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hypervisor/arch/x86/configs/vmptable.c b/hypervisor/arch/x86/configs/vmptable.c index 94becd2e4..1ee969847 100644 --- a/hypervisor/arch/x86/configs/vmptable.c +++ b/hypervisor/arch/x86/configs/vmptable.c @@ -85,10 +85,9 @@ static uint8_t mpt_compute_checksum(const void *base, size_t len) */ int32_t mptable_build(struct acrn_vm *vm) { - char *startaddr; - char *curraddr; struct mpcth *mpch; struct mpfps *mpfp; + struct mptable_info *mpinfo; size_t mptable_length; uint16_t i; uint16_t vcpu_num; @@ -127,14 +126,11 @@ int32_t mptable_build(struct acrn_vm *vm) /* Copy mptable info into guest memory */ (void)copy_to_gpa(vm, (void *)mptable, MPTABLE_BASE, mptable_length); - startaddr = (char *)gpa2hva(vm, MPTABLE_BASE); - curraddr = startaddr; + mpinfo = (struct mptable_info *) gpa2hva(vm, MPTABLE_BASE); stac(); - mpfp = (struct mpfps *)curraddr; + mpfp = &mpinfo->mpfp; mpfp->checksum = mpt_compute_checksum(mpfp, sizeof(struct mpfps)); - curraddr += sizeof(struct mpfps); - - mpch = (struct mpcth *)curraddr; + mpch = &mpinfo->mpch; mpch->checksum = mpt_compute_checksum(mpch, mpch->base_table_length); clac(); ret = 0;