Skip to content

Commit 9600dfa

Browse files
ShawnshhNanlinXie
authored andcommitted
fix "function return type inconsistent"
MISRA C required function return type should be consistented. Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 1a607b6 commit 9600dfa

File tree

11 files changed

+26
-25
lines changed

11 files changed

+26
-25
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ inline bool cpu_has_cap(uint32_t bit)
7777
if (feat_idx >= FEATURE_WORDS)
7878
return false;
7979

80-
return !!(boot_cpu_data.cpuid_leaves[feat_idx] & (1 << feat_bit));
80+
return ((boot_cpu_data.cpuid_leaves[feat_idx] & (1 << feat_bit)) != 0U);
8181
}
8282

8383
static inline bool get_monitor_cap(void)
@@ -250,7 +250,7 @@ static void alloc_phy_cpu_data(uint16_t pcpu_num)
250250
ASSERT(per_cpu_data_base_ptr != NULL, "");
251251
}
252252

253-
int __attribute__((weak)) parse_madt(uint8_t *lapic_id_base)
253+
uint16_t __attribute__((weak)) parse_madt(uint8_t *lapic_id_base)
254254
{
255255
static const uint32_t lapic_id[] = {0, 2, 4, 6};
256256
uint32_t i;

hypervisor/arch/x86/ept.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ uint64_t hpa2gpa(struct vm *vm, uint64_t hpa)
163163
| (hpa & (entry.page_size - 1)));
164164
}
165165

166-
int is_ept_supported(void)
166+
bool is_ept_supported(void)
167167
{
168-
uint16_t status;
168+
bool status;
169169
uint64_t tmp64;
170170

171171
/* Read primary processor based VM control. */
@@ -179,14 +179,14 @@ int is_ept_supported(void)
179179
/* Check if EPT is supported. */
180180
if ((tmp64 & (((uint64_t)VMX_PROCBASED_CTLS2_EPT) << 32)) != 0U) {
181181
/* EPT is present. */
182-
status = 1;
182+
status = true;
183183
} else {
184-
status = 0;
184+
status = false;
185185
}
186186

187187
} else {
188188
/* Secondary processor based VM control is not present */
189-
status = 0;
189+
status = false;
190190
}
191191

192192
return status;

hypervisor/arch/x86/mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ static inline void inv_tlb_one_page(void *addr)
109109

110110
static inline bool cpu_has_vmx_ept_cap(uint32_t bit_mask)
111111
{
112-
return !!(vmx_caps.ept & bit_mask);
112+
return ((vmx_caps.ept & bit_mask) != 0U);
113113
}
114114

115115
static inline bool cpu_has_vmx_vpid_cap(uint32_t bit_mask)
116116
{
117-
return !!(vmx_caps.vpid & bit_mask);
117+
return ((vmx_caps.vpid & bit_mask) != 0U);
118118
}
119119

120120
int check_vmx_mmu_cap(void)

hypervisor/arch/x86/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ static void init_exec_ctrl(struct vcpu *vcpu)
12011201
}
12021202

12031203
/* Check for EPT support */
1204-
if (is_ept_supported() != 0)
1204+
if (is_ept_supported())
12051205
pr_dbg("EPT is supported");
12061206
else
12071207
pr_err("Error: EPT is not supported");

hypervisor/common/schedule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ void release_schedule_lock(uint16_t pcpu_id)
3232
spinlock_release(&per_cpu(sched_ctx, pcpu_id).scheduler_lock);
3333
}
3434

35-
int allocate_pcpu(void)
35+
uint16_t allocate_pcpu(void)
3636
{
37-
int i;
37+
uint16_t i;
3838

3939
for (i = 0; i < phys_cpu_num; i++) {
4040
if (bitmap_test_and_set(i, &pcpu_used_bitmap) == 0)

hypervisor/debug/sbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static inline uint32_t sbuf_calculate_allocate_size(uint32_t ele_num,
3737
return 0;
3838
}
3939

40-
return sbuf_allocate_size;
40+
return (uint32_t) sbuf_allocate_size;
4141
}
4242

4343
struct shared_buf *sbuf_allocate(uint32_t ele_num, uint32_t ele_size)

hypervisor/debug/vuart.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int fifo_numchars(struct fifo *fifo)
9898
*
9999
* Return an interrupt reason if one is available.
100100
*/
101-
static int uart_intr_reason(struct vuart *vu)
101+
static uint8_t uart_intr_reason(struct vuart *vu)
102102
{
103103
if ((vu->lsr & LSR_OE) != 0 && (vu->ier & IER_ELSI) != 0)
104104
return IIR_RLS;
@@ -131,7 +131,7 @@ static void uart_init(struct vuart *vu)
131131
*/
132132
static void uart_toggle_intr(struct vuart *vu)
133133
{
134-
char intr_reason;
134+
uint8_t intr_reason;
135135

136136
intr_reason = uart_intr_reason(vu);
137137

@@ -229,7 +229,8 @@ static uint32_t uart_read(__unused struct vm_io_handler *hdlr,
229229
struct vm *vm, uint16_t offset,
230230
__unused size_t width)
231231
{
232-
char iir, intr_reason, reg;
232+
char iir, reg;
233+
uint8_t intr_reason;
233234
struct vuart *vu = vm_vuart(vm);
234235
offset -= vu->base;
235236
vuart_lock(vu);

hypervisor/include/arch/x86/mmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static inline void clflush(volatile void *p)
363363
extern uint8_t CPU_Boot_Page_Tables_Start_VM[];
364364

365365
/* External Interfaces */
366-
int is_ept_supported(void);
366+
bool is_ept_supported(void);
367367
uint64_t create_guest_initial_paging(struct vm *vm);
368368
void destroy_ept(struct vm *vm);
369369
uint64_t gpa2hpa(struct vm *vm, uint64_t gpa);

hypervisor/include/arch/x86/vmx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static inline uint8_t get_vcpu_mode(struct vcpu *vcpu)
425425

426426
static inline bool cpu_has_vmx_unrestricted_guest_cap(void)
427427
{
428-
return !!(msr_read(MSR_IA32_VMX_MISC) & VMX_SUPPORT_UNRESTRICTED_GUEST);
428+
return ((msr_read(MSR_IA32_VMX_MISC) & VMX_SUPPORT_UNRESTRICTED_GUEST) != 0UL);
429429
}
430430

431431
typedef struct _descriptor_table_{

hypervisor/include/common/schedule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void get_schedule_lock(uint16_t pcpu_id);
2323
void release_schedule_lock(uint16_t pcpu_id);
2424

2525
void set_pcpu_used(uint16_t pcpu_id);
26-
int allocate_pcpu(void);
26+
uint16_t allocate_pcpu(void);
2727
void free_pcpu(uint16_t pcpu_id);
2828

2929
void add_vcpu_to_runqueue(struct vcpu *vcpu);

0 commit comments

Comments
 (0)