Skip to content

Commit 496e400

Browse files
Shawnshhlijinxia
authored andcommitted
HV:treewide:fix rest of violations related parameter changed
Misra c required parameter should not changed in the scope of function,use local variable to replace it. Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com>
1 parent 42c77e4 commit 496e400

File tree

8 files changed

+35
-21
lines changed

8 files changed

+35
-21
lines changed

hypervisor/arch/x86/io.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ void free_io_emulation_resource(struct vm *vm)
177177
free(vm->arch_vm.iobitmap[1]);
178178
}
179179

180-
void allow_guest_io_access(struct vm *vm, uint32_t address, uint32_t nbytes)
180+
void allow_guest_io_access(struct vm *vm, uint32_t address_arg, uint32_t nbytes)
181181
{
182+
uint32_t address = address_arg;
182183
uint32_t *b;
183184
uint32_t i;
184185
uint32_t a;
@@ -194,8 +195,9 @@ void allow_guest_io_access(struct vm *vm, uint32_t address, uint32_t nbytes)
194195
}
195196
}
196197

197-
static void deny_guest_io_access(struct vm *vm, uint32_t address, uint32_t nbytes)
198+
static void deny_guest_io_access(struct vm *vm, uint32_t address_arg, uint32_t nbytes)
198199
{
200+
uint32_t address = address_arg;
199201
uint32_t *b;
200202
uint32_t i;
201203
uint32_t a;

hypervisor/arch/x86/timer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,13 @@ void check_tsc(void)
230230
CPU_CR_WRITE(cr4, (temp64 & ~CR4_TSD));
231231
}
232232

233-
static uint64_t pit_calibrate_tsc(uint16_t cal_ms)
233+
static uint64_t pit_calibrate_tsc(uint16_t cal_ms_arg)
234234
{
235235
#define PIT_TICK_RATE 1193182U
236236
#define PIT_TARGET 0x3FFFU
237237
#define PIT_MAX_COUNT 0xFFFFU
238238

239+
uint16_t cal_ms = cal_ms_arg;
239240
uint32_t initial_pit;
240241
uint16_t current_pit;
241242
uint16_t max_cal_ms;

hypervisor/debug/dump.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ static void dump_guest_context(uint16_t pcpu_id)
180180
}
181181
}
182182

183-
static void show_host_call_trace(uint64_t rsp, uint64_t rbp, uint16_t pcpu_id)
183+
static void show_host_call_trace(uint64_t rsp, uint64_t rbp_arg, uint16_t pcpu_id)
184184
{
185+
uint64_t rbp = rbp_arg;
185186
uint32_t i = 0U;
186187
uint32_t cb_hierarchy = 0U;
187188
uint64_t *sp = (uint64_t *)rsp;

hypervisor/debug/vuart.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ static void uart_toggle_intr(struct vuart *vu)
152152
}
153153

154154
static void uart_write(__unused struct vm_io_handler *hdlr,
155-
struct vm *vm, uint16_t offset,
155+
struct vm *vm, uint16_t offset_arg,
156156
__unused size_t width, uint32_t value)
157157
{
158+
uint16_t offset = offset_arg;
158159
struct vuart *vu = vm_vuart(vm);
159160
offset -= vu->base;
160161
vuart_lock(vu);
@@ -231,9 +232,10 @@ static void uart_write(__unused struct vm_io_handler *hdlr,
231232
}
232233

233234
static uint32_t uart_read(__unused struct vm_io_handler *hdlr,
234-
struct vm *vm, uint16_t offset,
235+
struct vm *vm, uint16_t offset_arg,
235236
__unused size_t width)
236237
{
238+
uint16_t offset = offset_arg;
237239
char iir, reg;
238240
uint8_t intr_reason;
239241
struct vuart *vu = vm_vuart(vm);

hypervisor/include/arch/x86/ioreq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct mem_io_node {
111111
int io_instr_vmexit_handler(struct vcpu *vcpu);
112112
void setup_io_bitmap(struct vm *vm);
113113
void free_io_emulation_resource(struct vm *vm);
114-
void allow_guest_io_access(struct vm *vm, uint32_t address, uint32_t nbytes);
114+
void allow_guest_io_access(struct vm *vm, uint32_t address_arg, uint32_t nbytes);
115115
void register_io_emulation_handler(struct vm *vm, struct vm_io_range *range,
116116
io_read_fn_t io_read_fn_ptr,
117117
io_write_fn_t io_write_fn_ptr);

hypervisor/include/lib/bits.h

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,10 @@ static inline uint16_t clz64(uint64_t value)
176176
* If nr>=64, it will be truncated.
177177
*/
178178
#define build_bitmap_set(name, op_len, op_type, lock, nr, addr) \
179-
static inline void name(uint16_t nr, volatile op_type *addr) \
179+
static inline void name(uint16_t nr_arg, volatile op_type *addr) \
180180
{ \
181-
nr = nr & ((8U * sizeof(op_type)) - 1U); \
181+
uint16_t nr; \
182+
nr = nr_arg & ((8U * sizeof(op_type)) - 1U); \
182183
asm volatile(lock "or" op_len " %1,%0" \
183184
: "+m" (*addr) \
184185
: "r" ((op_type)(1UL<<nr)) \
@@ -195,9 +196,10 @@ build_bitmap_set(bitmap32_set, "l", uint32_t, BUS_LOCK, nr, addr)
195196
* If nr>=64, it will be truncated.
196197
*/
197198
#define build_bitmap_clear(name, op_len, op_type, lock, nr, addr) \
198-
static inline void name(uint16_t nr, volatile op_type *addr) \
199+
static inline void name(uint16_t nr_arg, volatile op_type *addr) \
199200
{ \
200-
nr = nr & ((8U * sizeof(op_type)) - 1U); \
201+
uint16_t nr; \
202+
nr = nr_arg & ((8U * sizeof(op_type)) - 1U); \
201203
asm volatile(lock "and" op_len " %1,%0" \
202204
: "+m" (*addr) \
203205
: "r" ((op_type)(~(1UL<<(nr)))) \
@@ -213,21 +215,23 @@ build_bitmap_clear(bitmap32_clear, "l", uint32_t, BUS_LOCK, nr, addr)
213215
* Note:Input parameter nr shall be less than 64. If nr>=64, it will
214216
* be truncated.
215217
*/
216-
static inline bool bitmap_test(uint16_t nr, volatile uint64_t *addr)
218+
static inline bool bitmap_test(uint16_t nr_arg, volatile uint64_t *addr)
217219
{
220+
uint16_t nr;
218221
int32_t ret=0;
219-
nr = nr & 0x3fU;
222+
nr = nr_arg & 0x3fU;
220223
asm volatile("btq %q2,%1\n\tsbbl %0, %0"
221224
: "=r" (ret), "=m" (*addr)
222225
: "r" ((uint64_t)nr)
223226
: "cc", "memory");
224227
return (ret != 0);
225228
}
226229

227-
static inline bool bitmap32_test(uint16_t nr, volatile uint32_t *addr)
230+
static inline bool bitmap32_test(uint16_t nr_arg, volatile uint32_t *addr)
228231
{
232+
uint16_t nr;
229233
int32_t ret=0;
230-
nr = nr & 0x1fU;
234+
nr = nr_arg & 0x1fU;
231235
asm volatile("btl %2,%1\n\tsbbl %0, %0"
232236
: "=r" (ret), "=m" (*addr)
233237
: "r" ((uint32_t)nr)
@@ -243,10 +247,11 @@ static inline bool bitmap32_test(uint16_t nr, volatile uint32_t *addr)
243247
* will be truncated.
244248
*/
245249
#define build_bitmap_testandset(name, op_len, op_type, lock, nr, addr) \
246-
static inline bool name(uint16_t nr, volatile op_type *addr) \
250+
static inline bool name(uint16_t nr_arg, volatile op_type *addr) \
247251
{ \
252+
uint16_t nr; \
248253
int32_t ret=0; \
249-
nr = nr & ((8U * sizeof(op_type)) - 1U); \
254+
nr = nr_arg & ((8U * sizeof(op_type)) - 1U); \
250255
asm volatile(lock "bts" op_len " %2,%1\n\tsbbl %0,%0" \
251256
: "=r" (ret), "=m" (*addr) \
252257
: "r" ((op_type)nr) \
@@ -266,10 +271,11 @@ build_bitmap_testandset(bitmap32_test_and_set, "l", uint32_t, BUS_LOCK, nr, addr
266271
* it will be truncated.
267272
*/
268273
#define build_bitmap_testandclear(name, op_len, op_type, lock, nr, addr)\
269-
static inline bool name(uint16_t nr, volatile op_type *addr) \
274+
static inline bool name(uint16_t nr_arg, volatile op_type *addr) \
270275
{ \
276+
uint16_t nr; \
271277
int32_t ret=0; \
272-
nr = nr & ((8U * sizeof(op_type)) - 1U); \
278+
nr = nr_arg & ((8U * sizeof(op_type)) - 1U); \
273279
asm volatile(lock "btr" op_len " %2,%1\n\tsbbl %0,%0" \
274280
: "=r" (ret), "=m" (*addr) \
275281
: "r" ((op_type)nr) \

hypervisor/lib/div.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
#include <hv_lib.h>
88

9-
static int do_udiv32(uint32_t dividend_arg, uint32_t divisor,
9+
static int do_udiv32(uint32_t dividend_arg, uint32_t divisor_arg,
1010
struct udiv_result *res)
1111
{
1212
uint32_t dividend = dividend_arg;
13+
uint32_t divisor = divisor_arg;
1314
uint32_t mask;
1415
/* dividend is always greater than or equal to the divisor. Neither
1516
* divisor nor dividend are 0. Thus: * clz(dividend) and clz(divisor)

hypervisor/lib/sprintf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,9 @@ static int format_number(struct print_param *param)
281281
}
282282

283283
static int print_pow2(struct print_param *param,
284-
uint64_t v, uint32_t shift)
284+
uint64_t v_arg, uint32_t shift)
285285
{
286+
uint64_t v = v_arg;
286287
/* max buffer required for octal representation of unsigned long long */
287288
char digitbuff[22];
288289
/* Insert position for the next character+1 */

0 commit comments

Comments
 (0)