mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-16 08:26:41 +00:00
hv:fix MISRA-C return value violation
1) Change these 5 APIs to void type: vcpu_inject_pf uart16550_calc_baud_div uart16550_set_baud_rate console_init ptdev_activate_entry No need to return 'entry' for ptdev_activate_entry since the input parameter is 'entry'. 2) no need to check return value for the caller such as sbuf_put/console_putc/serial_puts/serial_get_rx_data Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
This commit is contained in:
parent
2a2adc76f6
commit
1d628c640c
@ -296,7 +296,7 @@ void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code)
|
||||
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
|
||||
}
|
||||
|
||||
int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code)
|
||||
void vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code)
|
||||
{
|
||||
struct run_context *cur_context =
|
||||
&vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context];
|
||||
@ -304,7 +304,6 @@ int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code)
|
||||
cur_context->cr2 = addr;
|
||||
vcpu_queue_exception(vcpu, IDT_PF, err_code);
|
||||
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int interrupt_window_vmexit_handler(struct vcpu *vcpu)
|
||||
|
@ -127,7 +127,7 @@ static int ptdev_interrupt_handler(__unused int irq, void *data)
|
||||
}
|
||||
|
||||
/* active intr with irq registering */
|
||||
struct ptdev_remapping_info *
|
||||
void
|
||||
ptdev_activate_entry(struct ptdev_remapping_info *entry, int phys_irq,
|
||||
bool lowpri)
|
||||
{
|
||||
@ -141,7 +141,6 @@ ptdev_activate_entry(struct ptdev_remapping_info *entry, int phys_irq,
|
||||
entry->node = node;
|
||||
|
||||
atomic_set_int(&entry->active, ACTIVE_FLAG);
|
||||
return entry;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -21,20 +21,18 @@ uint32_t get_serial_handle(void)
|
||||
|
||||
static void print_char(char x)
|
||||
{
|
||||
serial_puts(serial_handle, &x, 1);
|
||||
(void)serial_puts(serial_handle, &x, 1);
|
||||
|
||||
if (x == '\n') {
|
||||
serial_puts(serial_handle, "\r", 1);
|
||||
(void)serial_puts(serial_handle, "\r", 1);
|
||||
}
|
||||
}
|
||||
|
||||
int console_init(void)
|
||||
void console_init(void)
|
||||
{
|
||||
spinlock_init(&lock);
|
||||
|
||||
serial_handle = serial_open("STDIO");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int console_putc(int ch)
|
||||
@ -73,7 +71,7 @@ int console_puts(const char *s)
|
||||
}
|
||||
|
||||
/* write all characters up to p */
|
||||
serial_puts(serial_handle, s, p - s);
|
||||
(void)serial_puts(serial_handle, s, p - s);
|
||||
|
||||
res += p - s;
|
||||
|
||||
@ -116,7 +114,7 @@ int console_write(const char *s, size_t len)
|
||||
}
|
||||
|
||||
/* write all characters processed so far */
|
||||
serial_puts(serial_handle, s, p - s);
|
||||
(void)serial_puts(serial_handle, s, p - s);
|
||||
|
||||
res += p - s;
|
||||
|
||||
@ -156,14 +154,14 @@ void console_dump_bytes(const void *p, unsigned int len)
|
||||
/* print one row as ASCII characters (if possible) */
|
||||
for (i = 0; i < 16; i++) {
|
||||
if ((x[i] < ' ') || (x[i] >= 127)) {
|
||||
console_putc('.');
|
||||
(void)console_putc('.');
|
||||
}
|
||||
else {
|
||||
console_putc(x[i]);
|
||||
(void)console_putc(x[i]);
|
||||
}
|
||||
}
|
||||
/* continue with next row */
|
||||
console_putc('\n');
|
||||
(void)console_putc('\n');
|
||||
/* set pointer one row ahead */
|
||||
x += 16;
|
||||
}
|
||||
@ -175,7 +173,7 @@ static void console_read(void)
|
||||
|
||||
if (serial_handle != SERIAL_INVALID_HANDLE) {
|
||||
/* Get all the data available in the RX FIFO */
|
||||
serial_get_rx_data(serial_handle);
|
||||
(void)serial_get_rx_data(serial_handle);
|
||||
}
|
||||
|
||||
spinlock_release(&lock);
|
||||
|
@ -159,7 +159,7 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
|
||||
|
||||
for (i = 0; i < (msg_len - 1) / LOG_ENTRY_SIZE + 1;
|
||||
i++) {
|
||||
sbuf_put(sbuf, (uint8_t *)buffer +
|
||||
(void)sbuf_put(sbuf, (uint8_t *)buffer +
|
||||
i * LOG_ENTRY_SIZE);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ static int charout(int cmd, const char *s, int sz, void *hnd)
|
||||
/* fill mode */
|
||||
*nchars += sz;
|
||||
while (sz != 0) {
|
||||
console_putc(*s);
|
||||
(void)console_putc(*s);
|
||||
sz--;
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ uint32_t serial_get_rx_data(uint32_t uart_handle)
|
||||
spinlock_obtain(&uart->buffer_lock);
|
||||
|
||||
/* Put the item on circular buffer */
|
||||
sbuf_put(uart->rx_sio_queue, &ch);
|
||||
(void)sbuf_put(uart->rx_sio_queue, &ch);
|
||||
|
||||
/* Exit Critical Section */
|
||||
spinlock_release(&uart->buffer_lock);
|
||||
|
@ -1107,7 +1107,7 @@ void shell_puts_serial(struct shell *p_shell, char *string_ptr)
|
||||
(uint32_t)(uint64_t)p_shell->session_io.io_session_info;
|
||||
|
||||
/* Output the string */
|
||||
serial_puts(serial_handle, string_ptr,
|
||||
(void)serial_puts(serial_handle, string_ptr,
|
||||
strnlen_s(string_ptr, SHELL_STRING_MAX_LEN));
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ static void uart16550_enable(__unused struct tgt_uart *tgt_uart)
|
||||
{
|
||||
}
|
||||
|
||||
static int uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
|
||||
static void uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
|
||||
uint32_t ref_freq, uint32_t *baud_div_ptr, uint32_t baud_rate)
|
||||
{
|
||||
uint32_t baud_multiplier = baud_rate < BAUD_460800 ? 16 : 13;
|
||||
@ -93,39 +93,32 @@ static int uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
|
||||
baud_rate = BAUD_115200;
|
||||
}
|
||||
*baud_div_ptr = ref_freq / (baud_multiplier * baud_rate);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uart16550_set_baud_rate(struct tgt_uart *tgt_uart,
|
||||
static void uart16550_set_baud_rate(struct tgt_uart *tgt_uart,
|
||||
uint32_t baud_rate)
|
||||
{
|
||||
int status;
|
||||
uint32_t baud_div, duart_clock = CPU_OSC_CLOCK;
|
||||
uart_reg_t temp_reg;
|
||||
|
||||
/* Calculate baud divisor */
|
||||
status = uart16550_calc_baud_div(
|
||||
uart16550_calc_baud_div(
|
||||
tgt_uart, duart_clock, &baud_div, baud_rate);
|
||||
|
||||
if (status == 0) {
|
||||
/* Enable DLL and DLM registers for setting the Divisor */
|
||||
temp_reg = uart16550_read_reg(tgt_uart->base_address, LCR_IDX);
|
||||
temp_reg |= LCR_DLAB;
|
||||
uart16550_write_reg(tgt_uart->base_address, temp_reg, LCR_IDX);
|
||||
/* Enable DLL and DLM registers for setting the Divisor */
|
||||
temp_reg = uart16550_read_reg(tgt_uart->base_address, LCR_IDX);
|
||||
temp_reg |= LCR_DLAB;
|
||||
uart16550_write_reg(tgt_uart->base_address, temp_reg, LCR_IDX);
|
||||
|
||||
/* Write the appropriate divisor value */
|
||||
uart16550_write_reg(tgt_uart->base_address,
|
||||
/* Write the appropriate divisor value */
|
||||
uart16550_write_reg(tgt_uart->base_address,
|
||||
((baud_div >> 8) & 0xFFU), DLM_IDX);
|
||||
uart16550_write_reg(tgt_uart->base_address,
|
||||
uart16550_write_reg(tgt_uart->base_address,
|
||||
(baud_div & 0xFFU), DLL_IDX);
|
||||
|
||||
/* Disable DLL and DLM registers */
|
||||
temp_reg &= ~LCR_DLAB;
|
||||
uart16550_write_reg(tgt_uart->base_address, temp_reg, LCR_IDX);
|
||||
}
|
||||
|
||||
return status;
|
||||
/* Disable DLL and DLM registers */
|
||||
temp_reg &= ~LCR_DLAB;
|
||||
uart16550_write_reg(tgt_uart->base_address, temp_reg, LCR_IDX);
|
||||
}
|
||||
|
||||
static int uart16550_init(struct tgt_uart *tgt_uart)
|
||||
|
@ -97,7 +97,7 @@ extern spurious_handler_t spurious_handler;
|
||||
void vcpu_inject_extint(struct vcpu *vcpu);
|
||||
void vcpu_inject_nmi(struct vcpu *vcpu);
|
||||
void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code);
|
||||
int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code);
|
||||
void vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code);
|
||||
void vcpu_make_request(struct vcpu *vcpu, int eventid);
|
||||
int vcpu_queue_exception(struct vcpu *vcpu, uint32_t vector, uint32_t err_code);
|
||||
|
||||
|
@ -75,7 +75,7 @@ struct ptdev_remapping_info *ptdev_dequeue_softirq(void);
|
||||
struct ptdev_remapping_info *alloc_entry(struct vm *vm,
|
||||
enum ptdev_intr_type type);
|
||||
void release_entry(struct ptdev_remapping_info *entry);
|
||||
struct ptdev_remapping_info *ptdev_activate_entry(
|
||||
void ptdev_activate_entry(
|
||||
struct ptdev_remapping_info *entry,
|
||||
int phys_irq, bool lowpri);
|
||||
void ptdev_deactivate_entry(struct ptdev_remapping_info *entry);
|
||||
|
@ -12,12 +12,9 @@ extern struct timer console_timer;
|
||||
|
||||
/** Initializes the console module.
|
||||
*
|
||||
* @param cdev A pointer to the character device to use for the console.
|
||||
*
|
||||
* @return '0' on success. Any other value indicates an error.
|
||||
*/
|
||||
|
||||
int console_init(void);
|
||||
void console_init(void);
|
||||
|
||||
/** Writes a NUL terminated string to the console.
|
||||
*
|
||||
@ -76,9 +73,8 @@ static inline void resume_console(void)
|
||||
}
|
||||
|
||||
#else
|
||||
static inline int console_init(void)
|
||||
static inline void console_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int console_puts(__unused const char *str)
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ _trace_put(uint16_t cpu_id, uint32_t evid,
|
||||
entry->id = evid;
|
||||
entry->n_data = (uint8_t)n_data;
|
||||
entry->cpu = (uint8_t)cpu_id;
|
||||
sbuf_put(sbuf, (uint8_t *)entry);
|
||||
(void)sbuf_put(sbuf, (uint8_t *)entry);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
Loading…
Reference in New Issue
Block a user