mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 12:46:14 +00:00
Fix issues reported by Coverity and clear windows warnings (#2467)
This commit is contained in:
parent
4ce675aacd
commit
e2f8721ec9
|
@ -2605,9 +2605,16 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
|
||||||
|
|
||||||
while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) {
|
while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) {
|
||||||
if ((name = LLVMGetSymbolName(sym_itr))
|
if ((name = LLVMGetSymbolName(sym_itr))
|
||||||
&& !strcmp(name, aot_stack_sizes_alias_name)) {
|
&& (!strcmp(name, aot_stack_sizes_alias_name)
|
||||||
|
/* symbol of COFF32 starts with "_" */
|
||||||
|
|| (obj_data->target_info.bin_type == AOT_COFF32_BIN_TYPE
|
||||||
|
&& !strncmp(name, "_", 1)
|
||||||
|
&& !strcmp(name + 1, aot_stack_sizes_alias_name)))) {
|
||||||
uint64 sz = LLVMGetSymbolSize(sym_itr);
|
uint64 sz = LLVMGetSymbolSize(sym_itr);
|
||||||
if (sz != sizeof(uint32) * obj_data->func_count) {
|
if (sz != sizeof(uint32) * obj_data->func_count
|
||||||
|
/* sz of COFF64/COFF32 is 0, ignore the check */
|
||||||
|
&& obj_data->target_info.bin_type != AOT_COFF64_BIN_TYPE
|
||||||
|
&& obj_data->target_info.bin_type != AOT_COFF32_BIN_TYPE) {
|
||||||
aot_set_last_error("stack_sizes had unexpected size.");
|
aot_set_last_error("stack_sizes had unexpected size.");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -2642,10 +2649,6 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addr > UINT32_MAX) {
|
|
||||||
aot_set_last_error("too large stack_sizes offset.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Record section/offset and construct a copy of stack_sizes.
|
* Record section/offset and construct a copy of stack_sizes.
|
||||||
* aot_emit_object_data_section_info will emit this copy.
|
* aot_emit_object_data_section_info will emit this copy.
|
||||||
|
|
|
@ -1913,8 +1913,9 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memory_data) {
|
if (memory_data) {
|
||||||
bh_memcpy_s(memory_data + base_offset, memory_size - base_offset,
|
bh_memcpy_s(memory_data + base_offset,
|
||||||
data_seg->data, length);
|
(uint32)memory_size - base_offset, data_seg->data,
|
||||||
|
length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ tid_allocator_init(TidAllocator *tid_allocator)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int64 i = tid_allocator->pos - 1; i >= 0; i--)
|
for (int64 i = tid_allocator->pos - 1; i >= 0; i--)
|
||||||
tid_allocator->ids[i] = TID_MIN + (tid_allocator->pos - 1 - i);
|
tid_allocator->ids[i] =
|
||||||
|
(uint32)(TID_MIN + (tid_allocator->pos - 1 - i));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +55,8 @@ tid_allocator_get_tid(TidAllocator *tid_allocator)
|
||||||
LOG_ERROR("Overflow detected during realloc");
|
LOG_ERROR("Overflow detected during realloc");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int32 *tmp = wasm_runtime_realloc(tid_allocator->ids, realloc_size);
|
int32 *tmp =
|
||||||
|
wasm_runtime_realloc(tid_allocator->ids, (uint32)realloc_size);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
LOG_ERROR("Thread ID allocator realloc failed");
|
LOG_ERROR("Thread ID allocator realloc failed");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -64,7 +66,8 @@ tid_allocator_get_tid(TidAllocator *tid_allocator)
|
||||||
tid_allocator->pos = new_size - old_size;
|
tid_allocator->pos = new_size - old_size;
|
||||||
tid_allocator->ids = tmp;
|
tid_allocator->ids = tmp;
|
||||||
for (int64 i = tid_allocator->pos - 1; i >= 0; i--)
|
for (int64 i = tid_allocator->pos - 1; i >= 0; i--)
|
||||||
tid_allocator->ids[i] = TID_MIN + (tid_allocator->size - 1 - i);
|
tid_allocator->ids[i] =
|
||||||
|
(uint32)(TID_MIN + (tid_allocator->size - 1 - i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop available thread identifier from the stack
|
// Pop available thread identifier from the stack
|
||||||
|
@ -77,4 +80,4 @@ tid_allocator_release_tid(TidAllocator *tid_allocator, int32 thread_id)
|
||||||
// Release thread identifier by pushing it into the stack
|
// Release thread identifier by pushing it into the stack
|
||||||
bh_assert(tid_allocator->pos < tid_allocator->size);
|
bh_assert(tid_allocator->pos < tid_allocator->size);
|
||||||
tid_allocator->ids[tid_allocator->pos++] = thread_id;
|
tid_allocator->ids[tid_allocator->pos++] = thread_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ os_socket_recv_from(bh_socket_t socket, void *buf, unsigned int len, int flags,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (src_addr) {
|
||||||
memset(src_addr, 0, sizeof(*src_addr));
|
memset(src_addr, 0, sizeof(*src_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,7 @@ load_native_lib(const char *name)
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG_WARNING("warning: `init_native_lib` function from native "
|
LOG_WARNING("warning: `init_native_lib` function from native "
|
||||||
"lib %s failed with %d",
|
"lib %s failed with %d",
|
||||||
name);
|
name, ret);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user