From 7016244c22a73218a49d483bd0154dc6a42df3d1 Mon Sep 17 00:00:00 2001 From: Shiqing Gao Date: Tue, 25 Dec 2018 10:46:23 +0800 Subject: [PATCH] hv: io: fix MISRA-C violations related to break This patch fixes the MISRA-C violations in arch/x86/io.c * make the for loop have only one `break` Tracked-On: #861 Signed-off-by: Shiqing Gao Acked-by: Eddie Dong --- hypervisor/arch/x86/io.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hypervisor/arch/x86/io.c b/hypervisor/arch/x86/io.c index 95baa69ff..8314d1f38 100644 --- a/hypervisor/arch/x86/io.c +++ b/hypervisor/arch/x86/io.c @@ -247,6 +247,7 @@ hv_emulate_mmio(struct acrn_vcpu *vcpu, struct io_request *io_req) for (idx = 0U; idx < vcpu->vm->emul_mmio_regions; idx++) { uint64_t base, end; + bool emulation_done = false; mmio_handler = &(vcpu->vm->emul_mmio[idx]); base = mmio_handler->range_start; @@ -257,14 +258,18 @@ hv_emulate_mmio(struct acrn_vcpu *vcpu, struct io_request *io_req) } else if (!((address >= base) && ((address + size) <= end))) { pr_fatal("Err MMIO, address:0x%llx, size:%x", address, size); status = -EIO; - break; + emulation_done = true; } else { /* Handle this MMIO operation */ if (mmio_handler->read_write != NULL) { status = mmio_handler->read_write(io_req, mmio_handler->handler_private_data); - break; + emulation_done = true; } } + + if (emulation_done) { + break; + } } return status;