From 83d1ddc6d8c943dae830869851219ff6479e79e3 Mon Sep 17 00:00:00 2001 From: Junjun Shan Date: Thu, 13 Sep 2018 17:03:49 +0800 Subject: [PATCH] hv:Delete the dead code Delete the dead code get_irq_info(), local_get_irq_info() in io_request.c and definition in guest.h. v1->v2 *the dead code used pointers which not checked before use, therefore it causes "pointer not checked for null before use". To make it clearly, modify the subject to "delete the dead code" directly. *remove dead code local_get_irq_info() in io_request.c and definition in guest.h together. Tracked-On: #861 Signed-off-by: Junjun Shan Acked-by: Eddie Dong --- hypervisor/common/io_request.c | 102 ---------------------- hypervisor/include/arch/x86/guest/guest.h | 4 - 2 files changed, 106 deletions(-) diff --git a/hypervisor/common/io_request.c b/hypervisor/common/io_request.c index 970bc2dbb..4b9eaeb0c 100644 --- a/hypervisor/common/io_request.c +++ b/hypervisor/common/io_request.c @@ -100,105 +100,3 @@ acrn_insert_request_wait(struct vcpu *vcpu, struct io_request *io_req) return 0; } - -#ifdef HV_DEBUG -static void local_get_req_info_(struct vhm_request *req, int *id, char *type, - char *state, char *dir, uint64_t *addr, uint64_t *val) -{ - (void)strcpy_s(dir, 16U, "NONE"); - *addr = 0UL; - *val = 0UL; - *id = req->client; - - switch (req->type) { - case REQ_PORTIO: - (void)strcpy_s(type, 16U, "PORTIO"); - if (req->reqs.pio.direction == REQUEST_READ) { - (void)strcpy_s(dir, 16U, "READ"); - } else { - (void)strcpy_s(dir, 16U, "WRITE"); - } - *addr = req->reqs.pio.address; - *val = req->reqs.pio.value; - break; - case REQ_MMIO: - case REQ_WP: - (void)strcpy_s(type, 16U, "MMIO/WP"); - if (req->reqs.mmio.direction == REQUEST_READ) { - (void)strcpy_s(dir, 16U, "READ"); - } else { - (void)strcpy_s(dir, 16U, "WRITE"); - } - *addr = req->reqs.mmio.address; - *val = req->reqs.mmio.value; - break; - break; - default: - (void)strcpy_s(type, 16U, "UNKNOWN"); - } - - switch (req->processed) { - case REQ_STATE_COMPLETE: - (void)strcpy_s(state, 16U, "COMPLETE"); - break; - case REQ_STATE_PENDING: - (void)strcpy_s(state, 16U, "PENDING"); - break; - case REQ_STATE_PROCESSING: - (void)strcpy_s(state, 16U, "PROCESS"); - break; - case REQ_STATE_FREE: - (void)strcpy_s(state, 16U, "FREE"); - break; - default: - (void)strcpy_s(state, 16U, "UNKNOWN"); - } -} - -void get_req_info(char *str_arg, int str_max) -{ - char *str = str_arg; - uint32_t i; - int32_t len, size = str_max, client_id; - union vhm_request_buffer *req_buf; - struct vhm_request *req; - char type[16], state[16], dir[16]; - uint64_t addr, val; - struct list_head *pos; - struct vm *vm; - - len = snprintf(str, size, - "\r\nVM\tVCPU\tCID\tTYPE\tSTATE\tDIR\tADDR\t\t\tVAL"); - size -= len; - str += len; - - spinlock_obtain(&vm_list_lock); - list_for_each(pos, &vm_list) { - vm = list_entry(pos, struct vm, list); - req_buf = (union vhm_request_buffer *)vm->sw.io_shared_page; - if (req_buf != NULL) { - for (i = 0U; i < VHM_REQUEST_MAX; i++) { - req = req_buf->req_queue + i; - if (req->valid != 0) { - local_get_req_info_(req, &client_id, type, - state, dir, &addr, &val); - len = snprintf(str, size, - "\r\n%d\t%d\t%d\t%s\t%s\t%s", - vm->vm_id, i, client_id, type, - state, dir); - size -= len; - str += len; - - len = snprintf(str, size, - "\t0x%016llx\t0x%016llx", - addr, val); - size -= len; - str += len; - } - } - } - } - spinlock_release(&vm_list_lock); - snprintf(str, size, "\r\n"); -} -#endif /* HV_DEBUG */ diff --git a/hypervisor/include/arch/x86/guest/guest.h b/hypervisor/include/arch/x86/guest/guest.h index 1c53d9f1f..f2d41f4bc 100644 --- a/hypervisor/include/arch/x86/guest/guest.h +++ b/hypervisor/include/arch/x86/guest/guest.h @@ -142,10 +142,6 @@ int copy_to_gva(struct vcpu *vcpu, void *h_ptr, uint64_t gva, uint64_t create_guest_init_gdt(struct vm *vm, uint32_t *limit); extern uint8_t vm0_boot_context; -#ifdef HV_DEBUG -void get_req_info(char *str_arg, int str_max); -#endif /* HV_DEBUG */ - #endif /* !ASSEMBLER */ #endif /* GUEST_H*/