From 2ec1694901019b544816bf5b42a3a0c6d27e3c89 Mon Sep 17 00:00:00 2001 From: Huihuang Shi Date: Tue, 9 Jul 2019 11:20:04 +0800 Subject: [PATCH] HV: fix sbuf "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 Acked-by: Eddie Dong --- hypervisor/debug/logmsg.c | 2 +- hypervisor/debug/profiling.c | 16 ++++++---------- hypervisor/debug/sbuf.c | 2 +- hypervisor/debug/trace.c | 3 +-- hypervisor/include/arch/x86/per_cpu.h | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/hypervisor/debug/logmsg.c b/hypervisor/debug/logmsg.c index 49538cec9..baa413a13 100644 --- a/hypervisor/debug/logmsg.c +++ b/hypervisor/debug/logmsg.c @@ -89,7 +89,7 @@ void do_logmsg(uint32_t severity, const char *fmt, ...) /* Check if flags specify to output to memory */ if (do_mem_log) { uint32_t i, msg_len; - struct shared_buf *sbuf = (struct shared_buf *)per_cpu(sbuf, pcpu_id)[ACRN_HVLOG]; + struct shared_buf *sbuf = per_cpu(sbuf, pcpu_id)[ACRN_HVLOG]; /* If sbuf is not ready, we just drop the massage */ if (sbuf != NULL) { diff --git a/hypervisor/debug/profiling.c b/hypervisor/debug/profiling.c index cf12146cf..84a54e988 100644 --- a/hypervisor/debug/profiling.c +++ b/hypervisor/debug/profiling.c @@ -319,8 +319,7 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type) __func__, get_pcpu_id()); if (collector == COLLECT_PROFILE_DATA) { - sbuf = (struct shared_buf *) - per_cpu(sbuf, get_pcpu_id())[ACRN_SEP]; + sbuf = per_cpu(sbuf, get_pcpu_id())[ACRN_SEP]; if (sbuf == NULL) { ss->samples_dropped++; @@ -381,21 +380,18 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type) } for (i = 0U; i < (((DATA_HEADER_SIZE - 1U) / SEP_BUF_ENTRY_SIZE) + 1U); i++) { - (void)sbuf_put((struct shared_buf *)sbuf, - (uint8_t *)&pkt_header + i * SEP_BUF_ENTRY_SIZE); + (void)sbuf_put(sbuf, (uint8_t *)&pkt_header + i * SEP_BUF_ENTRY_SIZE); } for (i = 0U; i < (((payload_size - 1U) / SEP_BUF_ENTRY_SIZE) + 1U); i++) { - (void)sbuf_put((struct shared_buf *)sbuf, - (uint8_t *)payload + i * SEP_BUF_ENTRY_SIZE); + (void)sbuf_put(sbuf, (uint8_t *)payload + i * SEP_BUF_ENTRY_SIZE); } ss->samples_logged++; } } else if (collector == COLLECT_POWER_DATA) { - sbuf = (struct shared_buf *) - per_cpu(sbuf, get_pcpu_id())[ACRN_SOCWATCH]; + sbuf = per_cpu(sbuf, get_pcpu_id())[ACRN_SOCWATCH]; if (sbuf == NULL) { dev_dbg(ACRN_DBG_PROFILING, @@ -455,11 +451,11 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type) return 0; } /* copy header */ - (void)profiling_sbuf_put_variable((struct shared_buf *)sbuf, + (void)profiling_sbuf_put_variable(sbuf, (uint8_t *)&pkt_header, (uint32_t)DATA_HEADER_SIZE); /* copy payload */ - (void)profiling_sbuf_put_variable((struct shared_buf *)sbuf, + (void)profiling_sbuf_put_variable(sbuf, (uint8_t *)payload, (uint32_t)payload_size); spinlock_irqrestore_release(sw_lock, rflags); diff --git a/hypervisor/debug/sbuf.c b/hypervisor/debug/sbuf.c index 9a10bbb1f..516830d6a 100644 --- a/hypervisor/debug/sbuf.c +++ b/hypervisor/debug/sbuf.c @@ -85,7 +85,7 @@ int32_t sbuf_share_setup(uint16_t pcpu_id, uint32_t sbuf_id, uint64_t *hva) return -EINVAL; } - per_cpu(sbuf, pcpu_id)[sbuf_id] = hva; + per_cpu(sbuf, pcpu_id)[sbuf_id] = (struct shared_buf *) hva; pr_info("%s share sbuf for pCPU[%u] with sbuf_id[%u] setup successfully", __func__, pcpu_id, sbuf_id); diff --git a/hypervisor/debug/trace.c b/hypervisor/debug/trace.c index 9377dcf69..0ff7d9fdc 100644 --- a/hypervisor/debug/trace.c +++ b/hypervisor/debug/trace.c @@ -49,8 +49,7 @@ static inline bool trace_check(uint16_t cpu_id) static inline void trace_put(uint16_t cpu_id, uint32_t evid, uint32_t n_data, struct trace_entry *entry) { - struct shared_buf *sbuf = (struct shared_buf *) - per_cpu(sbuf, cpu_id)[ACRN_TRACE]; + struct shared_buf *sbuf = per_cpu(sbuf, cpu_id)[ACRN_TRACE]; entry->tsc = rdtsc(); entry->id = evid; diff --git a/hypervisor/include/arch/x86/per_cpu.h b/hypervisor/include/arch/x86/per_cpu.h index ebdf23106..a3cb5d651 100644 --- a/hypervisor/include/arch/x86/per_cpu.h +++ b/hypervisor/include/arch/x86/per_cpu.h @@ -24,7 +24,7 @@ struct per_cpu_region { uint8_t vmxon_region[PAGE_SIZE]; void *vmcs_run; #ifdef HV_DEBUG - uint64_t *sbuf[ACRN_SBUF_ID_MAX]; + struct shared_buf *sbuf[ACRN_SBUF_ID_MAX]; char logbuf[LOG_MESSAGE_MAX_SIZE]; uint32_t npk_log_ref; #endif