Skip to content

Commit 752e311

Browse files
mingqiangchilijinxia
authored andcommitted
hv:fixed MISRA-C return value violations
-- change send_start_ipi/do_copy_earlylog to void type -- drop the return value for vcpu_queue_execption when inject GP/PF/UD/AC/SS Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
1 parent 431ef57 commit 752e311

File tree

6 files changed

+14
-21
lines changed

6 files changed

+14
-21
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ void ptdev_softirq(__unused uint16_t cpu_id)
520520
ptdev_intr_handle_irq(vm, entry);
521521
} else {
522522
/* TODO: msi destmode check required */
523-
vlapic_intr_msi(vm,
523+
(void)vlapic_intr_msi(vm,
524524
msi->vmsi_addr,
525525
msi->vmsi_data);
526526
dev_dbg(ACRN_DBG_PTIRQ,

hypervisor/arch/x86/lapic.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,15 @@ uint8_t get_cur_lapic_id(void)
349349
return lapic_id;
350350
}
351351

352-
int
352+
/**
353+
* @pre cpu_startup_shorthand < INTR_CPU_STARTUP_UNKNOWN
354+
*/
355+
void
353356
send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,
354357
uint16_t dest_pcpu_id, uint64_t cpu_startup_start_address)
355358
{
356359
union apic_icr icr;
357360
uint8_t shorthand;
358-
int status = 0;
359-
360-
if (cpu_startup_shorthand >= INTR_CPU_STARTUP_UNKNOWN)
361-
status = -EINVAL;
362-
363-
ASSERT(status == 0, "Incorrect arguments");
364361

365362
icr.value = 0U;
366363
icr.bits.destination_mode = INTR_LAPIC_ICR_PHYSICAL;
@@ -412,8 +409,6 @@ send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,
412409
write_lapic_reg32(LAPIC_INT_COMMAND_REGISTER_1, icr.value_32.hi_32);
413410
write_lapic_reg32(LAPIC_INT_COMMAND_REGISTER_0, icr.value_32.lo_32);
414411
wait_for_delivery();
415-
416-
return status;
417412
}
418413

419414
/* dest_mode must be INTR_LAPIC_ICR_PHYSICAL(0x0U) or

hypervisor/arch/x86/virq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,36 +298,36 @@ void vcpu_inject_nmi(struct vcpu *vcpu)
298298
/* Inject general protection exception(#GP) to guest */
299299
void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code)
300300
{
301-
vcpu_queue_exception(vcpu, IDT_GP, err_code);
301+
(void)vcpu_queue_exception(vcpu, IDT_GP, err_code);
302302
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
303303
}
304304

305305
/* Inject page fault exception(#PF) to guest */
306306
void vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code)
307307
{
308308
vcpu_set_cr2(vcpu, addr);
309-
vcpu_queue_exception(vcpu, IDT_PF, err_code);
309+
(void)vcpu_queue_exception(vcpu, IDT_PF, err_code);
310310
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
311311
}
312312

313313
/* Inject invalid opcode exception(#UD) to guest */
314314
void vcpu_inject_ud(struct vcpu *vcpu)
315315
{
316-
vcpu_queue_exception(vcpu, IDT_UD, 0);
316+
(void)vcpu_queue_exception(vcpu, IDT_UD, 0);
317317
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
318318
}
319319

320320
/* Inject alignment check exception(#AC) to guest */
321321
void vcpu_inject_ac(struct vcpu *vcpu)
322322
{
323-
vcpu_queue_exception(vcpu, IDT_AC, 0);
323+
(void)vcpu_queue_exception(vcpu, IDT_AC, 0);
324324
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
325325
}
326326

327327
/* Inject stack fault exception(#SS) to guest */
328328
void vcpu_inject_ss(struct vcpu *vcpu)
329329
{
330-
vcpu_queue_exception(vcpu, IDT_SS, 0);
330+
(void)vcpu_queue_exception(vcpu, IDT_SS, 0);
331331
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
332332
}
333333

hypervisor/arch/x86/vmexit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int vmexit_handler(struct vcpu *vcpu)
175175
if (type == VMX_INT_TYPE_HW_EXP) {
176176
if ((vector_info & VMX_INT_INFO_ERR_CODE_VALID) != 0U)
177177
err_code = exec_vmread32(VMX_IDT_VEC_ERROR_CODE);
178-
vcpu_queue_exception(vcpu, vector, err_code);
178+
(void)vcpu_queue_exception(vcpu, vector, err_code);
179179
vcpu->arch_vcpu.idt_vectoring_info = 0U;
180180
} else if (type == VMX_INT_TYPE_NMI) {
181181
vcpu_make_request(vcpu, ACRN_REQUEST_NMI);

hypervisor/debug/logmsg.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static inline void free_earlylog_sbuf(uint16_t pcpu_id)
4242
per_cpu(earlylog_sbuf, pcpu_id) = NULL;
4343
}
4444

45-
static int do_copy_earlylog(struct shared_buf *dst_sbuf,
45+
static void do_copy_earlylog(struct shared_buf *dst_sbuf,
4646
struct shared_buf *src_sbuf)
4747
{
4848
uint32_t buf_size, valid_size;
@@ -54,7 +54,7 @@ static int do_copy_earlylog(struct shared_buf *dst_sbuf,
5454
spinlock_irqsave_obtain(&(logmsg.lock), &rflags);
5555
printf("Error to copy early hvlog: size mismatch\n");
5656
spinlock_irqrestore_release(&(logmsg.lock), rflags);
57-
return -EINVAL;
57+
return;
5858
}
5959

6060
cur_tail = src_sbuf->tail;
@@ -67,8 +67,6 @@ static int do_copy_earlylog(struct shared_buf *dst_sbuf,
6767
/* there is chance to lose new log from certain pcpu */
6868
dst_sbuf->tail = cur_tail;
6969
}
70-
71-
return 0;
7270
}
7371

7472
void init_logmsg(__unused uint32_t mem_size, uint32_t flags)

hypervisor/include/arch/x86/lapic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void early_init_lapic(void);
138138
void init_lapic(uint16_t pcpu_id);
139139
void send_lapic_eoi(void);
140140
uint8_t get_cur_lapic_id(void);
141-
int send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,
141+
void send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,
142142
uint16_t dest_pcpu_id,
143143
uint64_t cpu_startup_start_address);
144144
/* API to send an IPI to dest guest */

0 commit comments

Comments
 (0)