From 93d3d09aa1b21ffa657d6ae51761d97b416bdf04 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 28 Nov 2022 09:44:33 +0800 Subject: [PATCH] Clear some warnings and enable -Werror for NuttX (#1756) --- .github/workflows/compilation_on_nuttx.yml | 6 +----- core/iwasm/common/wasm_application.c | 2 +- core/iwasm/common/wasm_native.c | 10 ++++++++++ core/iwasm/interpreter/wasm_interp_classic.c | 5 +++-- .../libraries/libc-builtin/libc_builtin_wrapper.c | 4 ++-- core/shared/utils/bh_log.c | 2 +- product-mini/platforms/posix/main.c | 4 ++-- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/compilation_on_nuttx.yml b/.github/workflows/compilation_on_nuttx.yml index 15758a32b7..7df9e87ee9 100644 --- a/.github/workflows/compilation_on_nuttx.yml +++ b/.github/workflows/compilation_on_nuttx.yml @@ -55,12 +55,8 @@ jobs: "boards/sim/sim/sim/configs/nsh", # cortex-m0 "boards/arm/rp2040/raspberrypi-pico/configs/nsh", - # cortex-m4 - "boards/arm/stm32/stm32f4discovery/configs/nsh", # cortex-m7 "boards/arm/stm32h7/nucleo-h743zi/configs/nsh", - # cortex-a9 - "boards/arm/imx6/sabre-6quad/configs/nsh", # riscv32imac "boards/risc-v/qemu-rv/rv-virt/configs/nsh", # riscv64imac @@ -123,4 +119,4 @@ jobs: run: | cd nuttx tools/configure.sh ${{ matrix.nuttx_board_config }} - make -j$(nproc) + make -j$(nproc) EXTRAFLAGS=-Werror diff --git a/core/iwasm/common/wasm_application.c b/core/iwasm/common/wasm_application.c index 8a19de8ee5..8445652f64 100644 --- a/core/iwasm/common/wasm_application.c +++ b/core/iwasm/common/wasm_application.c @@ -555,7 +555,7 @@ execute_func(WASMModuleInstanceCommon *module_inst, const char *name, case VALUE_TYPE_FUNCREF: { if (argv1[k] != NULL_REF) - os_printf("%u:ref.func", argv1[k]); + os_printf("%" PRIu32 ":ref.func", argv1[k]); else os_printf("func:ref.null"); k++; diff --git a/core/iwasm/common/wasm_native.c b/core/iwasm/common/wasm_native.c index 91b156d377..c7be95fcf0 100644 --- a/core/iwasm/common/wasm_native.c +++ b/core/iwasm/common/wasm_native.c @@ -379,8 +379,13 @@ wasm_native_unregister_natives(const char *module_name, bool wasm_native_init() { +#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \ + || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \ + || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \ + || WASM_ENABLE_APP_FRAMEWORK != 0 NativeSymbol *native_symbols; uint32 n_native_symbols; +#endif #if WASM_ENABLE_LIBC_BUILTIN != 0 n_native_symbols = get_libc_builtin_export_apis(&native_symbols); @@ -456,9 +461,14 @@ wasm_native_init() #endif return true; +#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \ + || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \ + || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \ + || WASM_ENABLE_APP_FRAMEWORK != 0 fail: wasm_native_destroy(); return false; +#endif } void diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 95417f53bf..45ef4d567e 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -4094,8 +4094,9 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, if (argc < function->param_cell_num) { char buf[128]; snprintf(buf, sizeof(buf), - "invalid argument count %u, must be no smaller than %u", argc, - function->param_cell_num); + "invalid argument count %" PRIu32 + ", must be no smaller than %u", + argc, function->param_cell_num); wasm_set_exception(module_inst, buf); return; } diff --git a/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c b/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c index c24f789adc..55916deb46 100644 --- a/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c +++ b/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c @@ -952,13 +952,13 @@ print_wrapper(wasm_exec_env_t exec_env) static void print_i32_wrapper(wasm_exec_env_t exec_env, int32 i32) { - os_printf("in specttest.print_i32(%d)\n", i32); + os_printf("in specttest.print_i32(%" PRId32 ")\n", i32); } static void print_i32_f32_wrapper(wasm_exec_env_t exec_env, int32 i32, float f32) { - os_printf("in specttest.print_i32_f32(%d, %f)\n", i32, f32); + os_printf("in specttest.print_i32_f32(%" PRId32 ", %f)\n", i32, f32); } static void diff --git a/core/shared/utils/bh_log.c b/core/shared/utils/bh_log.c index 5e3a5b0f44..03dde4926f 100644 --- a/core/shared/utils/bh_log.c +++ b/core/shared/utils/bh_log.c @@ -102,6 +102,6 @@ void bh_log_proc_mem(const char *function, uint32 line) { char prompt[128] = { 0 }; - snprintf(prompt, sizeof(prompt), "[MEM] %s(...) L%u", function, line); + snprintf(prompt, sizeof(prompt), "[MEM] %s(...) L%" PRIu32, function, line); return bh_print_proc_mem(prompt); } \ No newline at end of file diff --git a/product-mini/platforms/posix/main.c b/product-mini/platforms/posix/main.c index 147e73866e..a0b3560b5a 100644 --- a/product-mini/platforms/posix/main.c +++ b/product-mini/platforms/posix/main.c @@ -78,7 +78,7 @@ print_help() } /* clang-format on */ -static void * +static const void * app_instance_main(wasm_module_inst_t module_inst) { const char *exception; @@ -89,7 +89,7 @@ app_instance_main(wasm_module_inst_t module_inst) return exception; } -static void * +static const void * app_instance_func(wasm_module_inst_t module_inst, const char *func_name) { wasm_application_execute_func(module_inst, func_name, app_argc - 1,