@@ -256,18 +256,19 @@ read_leb(const uint8 *buf, uint32 *p_offset, uint32 maxbits, bool sign)
256256 --frame_csp; \
257257 } while (0)
258258
259- #define POP_CSP_N (n ) \
260- do { \
261- uint32 *frame_sp_old = frame_sp; \
262- uint32 cell_num = 0; \
263- POP_CSP_CHECK_OVERFLOW(n + 1); \
264- frame_csp -= n; \
265- frame_ip = (frame_csp - 1)->target_addr; \
266- /* copy arity values of block */ \
267- frame_sp = (frame_csp - 1 )-> frame_sp ; \
268- cell_num = (frame_csp - 1 )-> cell_num ; \
269- word_copy (frame_sp , frame_sp_old - cell_num , cell_num ); \
270- frame_sp += cell_num ; \
259+ #define POP_CSP_N (n ) \
260+ do { \
261+ uint32 *frame_sp_old = frame_sp; \
262+ uint32 cell_num_to_copy; \
263+ POP_CSP_CHECK_OVERFLOW(n + 1); \
264+ frame_csp -= n; \
265+ frame_ip = (frame_csp - 1)->target_addr; \
266+ /* copy arity values of block */ \
267+ frame_sp = (frame_csp - 1 )-> frame_sp ; \
268+ cell_num_to_copy = (frame_csp - 1 )-> cell_num ; \
269+ word_copy (frame_sp , frame_sp_old - cell_num_to_copy , \
270+ cell_num_to_copy ); \
271+ frame_sp += cell_num_to_copy ; \
271272 } while (0 )
272273
273274/* Pop the given number of elements from the given frame's stack. */
@@ -367,11 +368,11 @@ read_leb(const uint8 *buf, uint32 *p_offset, uint32 maxbits, bool sign)
367368 PUSH_##src_op_type(cval); \
368369 } while (0)
369370
370- #define DEF_OP_EQZ (src_op_type ) \
371- do { \
372- int32 val ; \
373- val = POP_##src_op_type() == 0; \
374- PUSH_I32(val ); \
371+ #define DEF_OP_EQZ (src_op_type ) \
372+ do { \
373+ int32 pop_val ; \
374+ pop_val = POP_##src_op_type() == 0; \
375+ PUSH_I32(pop_val ); \
375376 } while (0)
376377
377378#define DEF_OP_CMP (src_type , src_op_type , cond ) \
@@ -434,9 +435,9 @@ read_leb(const uint8 *buf, uint32 *p_offset, uint32 maxbits, bool sign)
434435
435436#define DEF_OP_MATH (src_type , src_op_type , method ) \
436437 do { \
437- src_type val; \
438- val = POP_##src_op_type(); \
439- PUSH_##src_op_type(method(val )); \
438+ src_type src_val; \
439+ src_val = POP_##src_op_type(); \
440+ PUSH_##src_op_type(method(src_val )); \
440441 } while (0)
441442
442443#define TRUNC_FUNCTION (func_name , src_type , dst_type , signed_type ) \
@@ -1384,22 +1385,22 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
13841385
13851386 HANDLE_OP (WASM_OP_TABLE_SET )
13861387 {
1387- uint32 tbl_idx , elem_idx , val ;
1388+ uint32 tbl_idx , elem_idx , elem_val ;
13881389 WASMTableInstance * tbl_inst ;
13891390
13901391 read_leb_uint32 (frame_ip , frame_ip_end , tbl_idx );
13911392 bh_assert (tbl_idx < module -> table_count );
13921393
13931394 tbl_inst = wasm_get_table_inst (module , tbl_idx );
13941395
1395- val = POP_I32 ();
1396+ elem_val = POP_I32 ();
13961397 elem_idx = POP_I32 ();
13971398 if (elem_idx >= tbl_inst -> cur_size ) {
13981399 wasm_set_exception (module , "out of bounds table access" );
13991400 goto got_exception ;
14001401 }
14011402
1402- ((uint32 * )(tbl_inst -> base_addr ))[elem_idx ] = val ;
1403+ ((uint32 * )(tbl_inst -> base_addr ))[elem_idx ] = elem_val ;
14031404 HANDLE_OP_END ();
14041405 }
14051406
@@ -1414,9 +1415,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
14141415
14151416 HANDLE_OP (WASM_OP_REF_IS_NULL )
14161417 {
1417- uint32 val ;
1418- val = POP_I32 ();
1419- PUSH_I32 (val == NULL_REF ? 1 : 0 );
1418+ uint32 ref_val ;
1419+ ref_val = POP_I32 ();
1420+ PUSH_I32 (ref_val == NULL_REF ? 1 : 0 );
14201421 HANDLE_OP_END ();
14211422 }
14221423
@@ -2955,16 +2956,16 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
29552956 case WASM_OP_MEMORY_FILL :
29562957 {
29572958 uint32 dst , len ;
2958- uint8 val , * mdst ;
2959+ uint8 fill_val , * mdst ;
29592960 frame_ip ++ ;
29602961
29612962 len = POP_I32 ();
2962- val = POP_I32 ();
2963+ fill_val = POP_I32 ();
29632964 dst = POP_I32 ();
29642965
29652966 CHECK_BULK_MEMORY_OVERFLOW (dst , len , mdst );
29662967
2967- memset (mdst , val , len );
2968+ memset (mdst , fill_val , len );
29682969
29692970 break ;
29702971 }
@@ -3119,7 +3120,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
31193120 }
31203121 case WASM_OP_TABLE_FILL :
31213122 {
3122- uint32 tbl_idx , n , val , i ;
3123+ uint32 tbl_idx , n , fill_val ;
31233124 WASMTableInstance * tbl_inst ;
31243125
31253126 read_leb_uint32 (frame_ip , frame_ip_end , tbl_idx );
@@ -3128,7 +3129,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
31283129 tbl_inst = wasm_get_table_inst (module , tbl_idx );
31293130
31303131 n = POP_I32 ();
3131- val = POP_I32 ();
3132+ fill_val = POP_I32 ();
31323133 i = POP_I32 ();
31333134
31343135 /* TODO: what if the element is not passive? */
@@ -3142,7 +3143,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
31423143 }
31433144
31443145 for (; n != 0 ; i ++ , n -- ) {
3145- ((uint32 * )(tbl_inst -> base_addr ))[i ] = val ;
3146+ ((uint32 * )(tbl_inst -> base_addr ))[i ] = fill_val ;
31463147 }
31473148
31483149 break ;
@@ -3167,15 +3168,16 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
31673168 switch (opcode ) {
31683169 case WASM_OP_ATOMIC_NOTIFY :
31693170 {
3170- uint32 count , ret ;
3171+ uint32 notify_count , ret ;
31713172
3172- count = POP_I32 ();
3173+ notify_count = POP_I32 ();
31733174 addr = POP_I32 ();
31743175 CHECK_BULK_MEMORY_OVERFLOW (addr + offset , 4 , maddr );
31753176 CHECK_ATOMIC_MEMORY_ACCESS ();
31763177
31773178 ret = wasm_runtime_atomic_notify (
3178- (WASMModuleInstanceCommon * )module , maddr , count );
3179+ (WASMModuleInstanceCommon * )module , maddr ,
3180+ notify_count );
31793181 bh_assert ((int32 )ret >= 0 );
31803182
31813183 PUSH_I32 (ret );
@@ -3184,7 +3186,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
31843186 case WASM_OP_ATOMIC_WAIT32 :
31853187 {
31863188 uint64 timeout ;
3187- uint32 expect , addr , ret ;
3189+ uint32 expect , ret ;
31883190
31893191 timeout = POP_I64 ();
31903192 expect = POP_I32 ();
@@ -3708,13 +3710,15 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
37083710 frame here. */
37093711 unsigned frame_size = wasm_interp_interp_frame_size (all_cell_num );
37103712
3711- if (argc != function -> param_cell_num ) {
3713+ if (argc < function -> param_cell_num ) {
37123714 char buf [128 ];
3713- snprintf (buf , sizeof (buf ), "invalid argument count %d, expected %d" ,
3714- argc , function -> param_cell_num );
3715+ snprintf (buf , sizeof (buf ),
3716+ "invalid argument count %u, must be no smaller than %u" , argc ,
3717+ function -> param_cell_num );
37153718 wasm_set_exception (module_inst , buf );
37163719 return ;
37173720 }
3721+ argc = function -> param_cell_num ;
37183722
37193723 if ((uint8 * )& prev_frame < exec_env -> native_stack_boundary ) {
37203724 wasm_set_exception ((WASMModuleInstance * )exec_env -> module_inst ,
0 commit comments