Skip to content

Commit 2ec1694

Browse files
Shawnshhwenlingz
authored andcommitted
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 <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 79d0330 commit 2ec1694

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

hypervisor/debug/logmsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
8989
/* Check if flags specify to output to memory */
9090
if (do_mem_log) {
9191
uint32_t i, msg_len;
92-
struct shared_buf *sbuf = (struct shared_buf *)per_cpu(sbuf, pcpu_id)[ACRN_HVLOG];
92+
struct shared_buf *sbuf = per_cpu(sbuf, pcpu_id)[ACRN_HVLOG];
9393

9494
/* If sbuf is not ready, we just drop the massage */
9595
if (sbuf != NULL) {

hypervisor/debug/profiling.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,7 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type)
319319
__func__, get_pcpu_id());
320320

321321
if (collector == COLLECT_PROFILE_DATA) {
322-
sbuf = (struct shared_buf *)
323-
per_cpu(sbuf, get_pcpu_id())[ACRN_SEP];
322+
sbuf = per_cpu(sbuf, get_pcpu_id())[ACRN_SEP];
324323

325324
if (sbuf == NULL) {
326325
ss->samples_dropped++;
@@ -381,21 +380,18 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type)
381380
}
382381

383382
for (i = 0U; i < (((DATA_HEADER_SIZE - 1U) / SEP_BUF_ENTRY_SIZE) + 1U); i++) {
384-
(void)sbuf_put((struct shared_buf *)sbuf,
385-
(uint8_t *)&pkt_header + i * SEP_BUF_ENTRY_SIZE);
383+
(void)sbuf_put(sbuf, (uint8_t *)&pkt_header + i * SEP_BUF_ENTRY_SIZE);
386384
}
387385

388386
for (i = 0U; i < (((payload_size - 1U) / SEP_BUF_ENTRY_SIZE) + 1U); i++) {
389-
(void)sbuf_put((struct shared_buf *)sbuf,
390-
(uint8_t *)payload + i * SEP_BUF_ENTRY_SIZE);
387+
(void)sbuf_put(sbuf, (uint8_t *)payload + i * SEP_BUF_ENTRY_SIZE);
391388
}
392389

393390
ss->samples_logged++;
394391
}
395392
} else if (collector == COLLECT_POWER_DATA) {
396393

397-
sbuf = (struct shared_buf *)
398-
per_cpu(sbuf, get_pcpu_id())[ACRN_SOCWATCH];
394+
sbuf = per_cpu(sbuf, get_pcpu_id())[ACRN_SOCWATCH];
399395

400396
if (sbuf == NULL) {
401397
dev_dbg(ACRN_DBG_PROFILING,
@@ -455,11 +451,11 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type)
455451
return 0;
456452
}
457453
/* copy header */
458-
(void)profiling_sbuf_put_variable((struct shared_buf *)sbuf,
454+
(void)profiling_sbuf_put_variable(sbuf,
459455
(uint8_t *)&pkt_header, (uint32_t)DATA_HEADER_SIZE);
460456

461457
/* copy payload */
462-
(void)profiling_sbuf_put_variable((struct shared_buf *)sbuf,
458+
(void)profiling_sbuf_put_variable(sbuf,
463459
(uint8_t *)payload, (uint32_t)payload_size);
464460

465461
spinlock_irqrestore_release(sw_lock, rflags);

hypervisor/debug/sbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int32_t sbuf_share_setup(uint16_t pcpu_id, uint32_t sbuf_id, uint64_t *hva)
8585
return -EINVAL;
8686
}
8787

88-
per_cpu(sbuf, pcpu_id)[sbuf_id] = hva;
88+
per_cpu(sbuf, pcpu_id)[sbuf_id] = (struct shared_buf *) hva;
8989
pr_info("%s share sbuf for pCPU[%u] with sbuf_id[%u] setup successfully",
9090
__func__, pcpu_id, sbuf_id);
9191

hypervisor/debug/trace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ static inline bool trace_check(uint16_t cpu_id)
4949

5050
static inline void trace_put(uint16_t cpu_id, uint32_t evid, uint32_t n_data, struct trace_entry *entry)
5151
{
52-
struct shared_buf *sbuf = (struct shared_buf *)
53-
per_cpu(sbuf, cpu_id)[ACRN_TRACE];
52+
struct shared_buf *sbuf = per_cpu(sbuf, cpu_id)[ACRN_TRACE];
5453

5554
entry->tsc = rdtsc();
5655
entry->id = evid;

hypervisor/include/arch/x86/per_cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct per_cpu_region {
2424
uint8_t vmxon_region[PAGE_SIZE];
2525
void *vmcs_run;
2626
#ifdef HV_DEBUG
27-
uint64_t *sbuf[ACRN_SBUF_ID_MAX];
27+
struct shared_buf *sbuf[ACRN_SBUF_ID_MAX];
2828
char logbuf[LOG_MESSAGE_MAX_SIZE];
2929
uint32_t npk_log_ref;
3030
#endif

0 commit comments

Comments
 (0)