Skip to content

Commit 1d628c6

Browse files
mingqiangchilijinxia
authored andcommitted
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>
1 parent 2a2adc7 commit 1d628c6

File tree

12 files changed

+33
-48
lines changed

12 files changed

+33
-48
lines changed

hypervisor/arch/x86/virq.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,14 @@ void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code)
296296
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
297297
}
298298

299-
int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code)
299+
void vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code)
300300
{
301301
struct run_context *cur_context =
302302
&vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context];
303303

304304
cur_context->cr2 = addr;
305305
vcpu_queue_exception(vcpu, IDT_PF, err_code);
306306
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
307-
return 0;
308307
}
309308

310309
int interrupt_window_vmexit_handler(struct vcpu *vcpu)

hypervisor/common/ptdev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int ptdev_interrupt_handler(__unused int irq, void *data)
127127
}
128128

129129
/* active intr with irq registering */
130-
struct ptdev_remapping_info *
130+
void
131131
ptdev_activate_entry(struct ptdev_remapping_info *entry, int phys_irq,
132132
bool lowpri)
133133
{
@@ -141,7 +141,6 @@ ptdev_activate_entry(struct ptdev_remapping_info *entry, int phys_irq,
141141
entry->node = node;
142142

143143
atomic_set_int(&entry->active, ACTIVE_FLAG);
144-
return entry;
145144
}
146145

147146
void

hypervisor/debug/console.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,18 @@ uint32_t get_serial_handle(void)
2121

2222
static void print_char(char x)
2323
{
24-
serial_puts(serial_handle, &x, 1);
24+
(void)serial_puts(serial_handle, &x, 1);
2525

2626
if (x == '\n') {
27-
serial_puts(serial_handle, "\r", 1);
27+
(void)serial_puts(serial_handle, "\r", 1);
2828
}
2929
}
3030

31-
int console_init(void)
31+
void console_init(void)
3232
{
3333
spinlock_init(&lock);
3434

3535
serial_handle = serial_open("STDIO");
36-
37-
return 0;
3836
}
3937

4038
int console_putc(int ch)
@@ -73,7 +71,7 @@ int console_puts(const char *s)
7371
}
7472

7573
/* write all characters up to p */
76-
serial_puts(serial_handle, s, p - s);
74+
(void)serial_puts(serial_handle, s, p - s);
7775

7876
res += p - s;
7977

@@ -116,7 +114,7 @@ int console_write(const char *s, size_t len)
116114
}
117115

118116
/* write all characters processed so far */
119-
serial_puts(serial_handle, s, p - s);
117+
(void)serial_puts(serial_handle, s, p - s);
120118

121119
res += p - s;
122120

@@ -156,14 +154,14 @@ void console_dump_bytes(const void *p, unsigned int len)
156154
/* print one row as ASCII characters (if possible) */
157155
for (i = 0; i < 16; i++) {
158156
if ((x[i] < ' ') || (x[i] >= 127)) {
159-
console_putc('.');
157+
(void)console_putc('.');
160158
}
161159
else {
162-
console_putc(x[i]);
160+
(void)console_putc(x[i]);
163161
}
164162
}
165163
/* continue with next row */
166-
console_putc('\n');
164+
(void)console_putc('\n');
167165
/* set pointer one row ahead */
168166
x += 16;
169167
}
@@ -175,7 +173,7 @@ static void console_read(void)
175173

176174
if (serial_handle != SERIAL_INVALID_HANDLE) {
177175
/* Get all the data available in the RX FIFO */
178-
serial_get_rx_data(serial_handle);
176+
(void)serial_get_rx_data(serial_handle);
179177
}
180178

181179
spinlock_release(&lock);

hypervisor/debug/logmsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
159159

160160
for (i = 0; i < (msg_len - 1) / LOG_ENTRY_SIZE + 1;
161161
i++) {
162-
sbuf_put(sbuf, (uint8_t *)buffer +
162+
(void)sbuf_put(sbuf, (uint8_t *)buffer +
163163
i * LOG_ENTRY_SIZE);
164164
}
165165
}

hypervisor/debug/printf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static int charout(int cmd, const char *s, int sz, void *hnd)
2828
/* fill mode */
2929
*nchars += sz;
3030
while (sz != 0) {
31-
console_putc(*s);
31+
(void)console_putc(*s);
3232
sz--;
3333
}
3434
}

hypervisor/debug/serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ uint32_t serial_get_rx_data(uint32_t uart_handle)
178178
spinlock_obtain(&uart->buffer_lock);
179179

180180
/* Put the item on circular buffer */
181-
sbuf_put(uart->rx_sio_queue, &ch);
181+
(void)sbuf_put(uart->rx_sio_queue, &ch);
182182

183183
/* Exit Critical Section */
184184
spinlock_release(&uart->buffer_lock);

hypervisor/debug/shell_internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ void shell_puts_serial(struct shell *p_shell, char *string_ptr)
11071107
(uint32_t)(uint64_t)p_shell->session_io.io_session_info;
11081108

11091109
/* Output the string */
1110-
serial_puts(serial_handle, string_ptr,
1110+
(void)serial_puts(serial_handle, string_ptr,
11111111
strnlen_s(string_ptr, SHELL_STRING_MAX_LEN));
11121112
}
11131113

hypervisor/debug/uart16550.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void uart16550_enable(__unused struct tgt_uart *tgt_uart)
8484
{
8585
}
8686

87-
static int uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
87+
static void uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
8888
uint32_t ref_freq, uint32_t *baud_div_ptr, uint32_t baud_rate)
8989
{
9090
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,
9393
baud_rate = BAUD_115200;
9494
}
9595
*baud_div_ptr = ref_freq / (baud_multiplier * baud_rate);
96-
97-
return 0;
9896
}
9997

100-
static int uart16550_set_baud_rate(struct tgt_uart *tgt_uart,
98+
static void uart16550_set_baud_rate(struct tgt_uart *tgt_uart,
10199
uint32_t baud_rate)
102100
{
103-
int status;
104101
uint32_t baud_div, duart_clock = CPU_OSC_CLOCK;
105102
uart_reg_t temp_reg;
106103

107104
/* Calculate baud divisor */
108-
status = uart16550_calc_baud_div(
105+
uart16550_calc_baud_div(
109106
tgt_uart, duart_clock, &baud_div, baud_rate);
110107

111-
if (status == 0) {
112-
/* Enable DLL and DLM registers for setting the Divisor */
113-
temp_reg = uart16550_read_reg(tgt_uart->base_address, LCR_IDX);
114-
temp_reg |= LCR_DLAB;
115-
uart16550_write_reg(tgt_uart->base_address, temp_reg, LCR_IDX);
108+
/* Enable DLL and DLM registers for setting the Divisor */
109+
temp_reg = uart16550_read_reg(tgt_uart->base_address, LCR_IDX);
110+
temp_reg |= LCR_DLAB;
111+
uart16550_write_reg(tgt_uart->base_address, temp_reg, LCR_IDX);
116112

117-
/* Write the appropriate divisor value */
118-
uart16550_write_reg(tgt_uart->base_address,
113+
/* Write the appropriate divisor value */
114+
uart16550_write_reg(tgt_uart->base_address,
119115
((baud_div >> 8) & 0xFFU), DLM_IDX);
120-
uart16550_write_reg(tgt_uart->base_address,
116+
uart16550_write_reg(tgt_uart->base_address,
121117
(baud_div & 0xFFU), DLL_IDX);
122118

123-
/* Disable DLL and DLM registers */
124-
temp_reg &= ~LCR_DLAB;
125-
uart16550_write_reg(tgt_uart->base_address, temp_reg, LCR_IDX);
126-
}
127-
128-
return status;
119+
/* Disable DLL and DLM registers */
120+
temp_reg &= ~LCR_DLAB;
121+
uart16550_write_reg(tgt_uart->base_address, temp_reg, LCR_IDX);
129122
}
130123

131124
static int uart16550_init(struct tgt_uart *tgt_uart)

hypervisor/include/arch/x86/irq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ extern spurious_handler_t spurious_handler;
9797
void vcpu_inject_extint(struct vcpu *vcpu);
9898
void vcpu_inject_nmi(struct vcpu *vcpu);
9999
void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code);
100-
int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code);
100+
void vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code);
101101
void vcpu_make_request(struct vcpu *vcpu, int eventid);
102102
int vcpu_queue_exception(struct vcpu *vcpu, uint32_t vector, uint32_t err_code);
103103

hypervisor/include/common/ptdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct ptdev_remapping_info *ptdev_dequeue_softirq(void);
7575
struct ptdev_remapping_info *alloc_entry(struct vm *vm,
7676
enum ptdev_intr_type type);
7777
void release_entry(struct ptdev_remapping_info *entry);
78-
struct ptdev_remapping_info *ptdev_activate_entry(
78+
void ptdev_activate_entry(
7979
struct ptdev_remapping_info *entry,
8080
int phys_irq, bool lowpri);
8181
void ptdev_deactivate_entry(struct ptdev_remapping_info *entry);

0 commit comments

Comments
 (0)