Fix warnings/issues reported in Windows and by CodeQL/Coverity (#3275)

Fix the warnings and issues reported:
- in Windows platform
- by CodeQL static code analyzing
- by Coverity static code analyzing

And update CodeQL script to build exception handling and memory features.
This commit is contained in:
Wenyong Huang
2024-04-07 11:57:31 +08:00
committed by GitHub
parent 53f0941ffa
commit 2013f1f7d7
26 changed files with 202 additions and 118 deletions

View File

@ -330,7 +330,7 @@ aot_gen_commit_values(AOTCompFrame *frame)
if (!p->dirty)
continue;
n = p - frame->lp;
n = (uint32)(p - frame->lp);
/* Commit reference flag */
if (comp_ctx->enable_gc) {
@ -432,7 +432,7 @@ aot_gen_commit_values(AOTCompFrame *frame)
continue;
p->dirty = 0;
n = p - frame->lp;
n = (uint32)(p - frame->lp);
/* Commit values */
switch (p->type) {
@ -538,7 +538,7 @@ aot_gen_commit_values(AOTCompFrame *frame)
/* Clear reference flags for unused stack slots. */
for (p = frame->sp; p < end; p++) {
bh_assert(!p->ref);
n = p - frame->lp;
n = (uint32)(p - frame->lp);
/* Commit reference flag. */
if (p->ref != p->committed_ref - 1) {
@ -621,7 +621,7 @@ aot_gen_commit_sp_ip(AOTCompFrame *frame, bool commit_sp, bool commit_ip)
}
if (commit_sp) {
n = sp - frame->lp;
n = (uint32)(sp - frame->lp);
value = I32_CONST(offset_of_local(comp_ctx, n));
if (!value) {
aot_set_last_error("llvm build const failed");

View File

@ -1269,6 +1269,7 @@ aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
PUSH(values[j], target_block->result_types[j]);
}
wasm_runtime_free(values);
values = NULL;
}
target_block->is_reachable = true;
if (i == br_count)
@ -1294,6 +1295,7 @@ aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
PUSH(values[j], target_block->param_types[j]);
}
wasm_runtime_free(values);
values = NULL;
}
if (i == br_count)
default_llvm_block = target_block->llvm_entry_block;

View File

@ -674,7 +674,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
uint32 backend_thread_num, compile_thread_num;
/* Check function parameter types and result types */
for (i = 0; i < aot_func_type->param_count + aot_func_type->result_count;
for (i = 0;
i < (uint32)(aot_func_type->param_count + aot_func_type->result_count);
i++) {
if (!check_wasm_type(comp_ctx, aot_func_type->types[i]))
return NULL;