From 58570a50048c102e1bab3a597744235f85687f9d Mon Sep 17 00:00:00 2001 From: QuangHaiNguyen Date: Sat, 11 Apr 2026 02:28:27 +0200 Subject: [PATCH] Fix compiler errors/warnings - Activate several common build flag (check CMake file in src) - Fix all compiler errors/warnings --- .github/workflows/document_build.yaml | 2 +- .github/workflows/linux_build.yaml | 5 ++ .github/workflows/linux_unit_test.yaml | 5 ++ CMakeLists.txt | 14 ++---- CMakePresets.json | 19 +++++-- cmake/ez_version.h.in | 10 ---- inc/ez_version.h | 4 +- inc/middlewares/osal/ez_osal.h | 5 +- inc/service/cli/ez_cli.h | 2 +- inc/service/data_model/ez_data_model.h | 2 +- inc/service/rpc/ez_rpc.h | 4 +- inc/utilities/hexdump/ez_hexdump.h | 2 +- inc/utilities/logging/ez_logging.h | 48 +++++++++--------- samples/linux/main.c | 3 +- src/CMakeLists.txt | 22 ++++++++ src/hal/gpio/ez_gpio.c | 2 - src/hal/uart/ez_uart.c | 2 + src/middlewares/osal/CMakeLists.txt | 8 +++ src/middlewares/osal/ez_osal_freertos.c | 5 +- src/middlewares/osal/ez_osal_threadx.c | 6 ++- src/service/cli/ez_cli.c | 17 +++---- src/service/data_model/ez_data_model.c | 8 +-- src/service/event_bus/ez_event_bus.c | 3 +- src/service/ipc/ez_ipc.c | 2 + src/service/rpc/ez_rpc.c | 33 ++++++------ src/service/state_machine/ez_state_machine.c | 2 +- src/service/task_worker/ez_task_worker.c | 12 ++--- src/utilities/CMakeLists.txt | 1 - src/utilities/assert/ez_assert.c | 50 ------------------- src/utilities/hexdump/ez_hexdump.c | 24 +++++---- src/utilities/queue/ez_queue.c | 18 +++---- tests/service/cli/unittest_ez_cli.c | 7 ++- .../datamodel/unittest_ez_datamodel.cpp | 25 +++++----- tests/service/driver/uart/unittest_ez_uart.c | 20 +++++++- .../service/event_bus/unittest_ez_event_bus.c | 2 +- tests/service/rpc/unittest_ez_rpc.cpp | 5 ++ .../state_machine/unittest_ez_state_machine.c | 10 +++- .../task_worker/unittest_ez_task_worker.c | 1 - .../linked_list/unittest_ez_linked_list.c | 2 - tests/utilities/queue/unittest_ez_queue.c | 1 - 40 files changed, 216 insertions(+), 197 deletions(-) delete mode 100644 cmake/ez_version.h.in delete mode 100755 src/utilities/assert/ez_assert.c diff --git a/.github/workflows/document_build.yaml b/.github/workflows/document_build.yaml index 8a878c2b..4076ba47 100644 --- a/.github/workflows/document_build.yaml +++ b/.github/workflows/document_build.yaml @@ -17,7 +17,7 @@ jobs: pwd ls -al pip install -r ./docs/requirements.txt - + - id: deployment uses: sphinx-notes/pages@v3 with: diff --git a/.github/workflows/linux_build.yaml b/.github/workflows/linux_build.yaml index 391834ec..fd6f79ff 100644 --- a/.github/workflows/linux_build.yaml +++ b/.github/workflows/linux_build.yaml @@ -13,6 +13,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install build tools + run: | + sudo apt-get update + sudo apt-get install -y gcc-multilib g++-multilib + - name: Configure linux_threadx_debug working-directory: ${{github.workspace}} run: cmake --preset=linux_threadx_debug diff --git a/.github/workflows/linux_unit_test.yaml b/.github/workflows/linux_unit_test.yaml index 4d358763..ae70e134 100644 --- a/.github/workflows/linux_unit_test.yaml +++ b/.github/workflows/linux_unit_test.yaml @@ -13,6 +13,11 @@ jobs: - uses: actions/checkout@v3 - uses: threeal/gcovr-action@v1.1.0 + - name: Install build tools + run: | + sudo apt-get update + sudo apt-get install -y gcc-multilib g++-multilib + - name: Configure linux_test_debug working-directory: ${{github.workspace}} run: cmake --preset=linux_test_debug diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b172ca4..827c3b2b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,16 @@ cmake_minimum_required(VERSION 3.25) project(EzEmbeddedFramework - VERSION 1.0.0 + VERSION 1.0.2 LANGUAGES C CXX DESCRIPTION "Easy Embedded Software Framework" ) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(BUILD_NUMBER 0) - +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++20 (not gnu++20) -# Configure a header file with version + build number -configure_file( - cmake/ez_version.h.in - inc/ez_version.h -) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) #Only build test, targets, and extern when being build as a project if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) diff --git a/CMakePresets.json b/CMakePresets.json index 2b12b93a..bfe0daa2 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -18,7 +18,10 @@ "rhs": "Linux" }, "cacheVariables": { - "TARGET_PATH": "samples/linux" + "TARGET_PATH": "samples/linux", + "CMAKE_C_FLAGS": "-m32", + "CMAKE_CXX_FLAGS": "-m32", + "CMAKE_EXE_LINKER_FLAGS": "-m32" } }, { @@ -35,7 +38,10 @@ "cacheVariables": { "TARGET_PATH": "samples/linux_threadx", "THREADX_ARCH": "linux", - "THREADX_TOOLCHAIN": "gnu" + "THREADX_TOOLCHAIN": "gnu", + "CMAKE_C_FLAGS": "-m32", + "CMAKE_CXX_FLAGS": "-m32", + "CMAKE_EXE_LINKER_FLAGS": "-m32" } }, { @@ -50,7 +56,10 @@ "rhs": "Linux" }, "cacheVariables": { - "TARGET_PATH": "samples/linux_freertos" + "TARGET_PATH": "samples/linux_freertos", + "CMAKE_C_FLAGS": "-m32", + "CMAKE_CXX_FLAGS": "-m32", + "CMAKE_EXE_LINKER_FLAGS": "-m32" } }, { @@ -81,7 +90,9 @@ "binaryDir": "${sourceDir}/build_linux_test_debug", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_C_FLAGS":"-fprofile-arcs -ftest-coverage -fPIC" + "CMAKE_C_FLAGS": "-m32 -fprofile-arcs -ftest-coverage -fPIC", + "CMAKE_CXX_FLAGS": "-m32", + "CMAKE_EXE_LINKER_FLAGS": "-m32" } }, { diff --git a/cmake/ez_version.h.in b/cmake/ez_version.h.in deleted file mode 100644 index 049ca64a..00000000 --- a/cmake/ez_version.h.in +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef VERSION_H -#define VERSION_H - -#define EZ_SDK_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ -#define EZ_SDK_VERSION_MINOR @PROJECT_VERSION_MINOR@ -#define EZ_SDK_VERSION_PATCH @PROJECT_VERSION_PATCH@ -#define EZ_SDK_BUILD_NUMBER @BUILD_NUMBER@ -#define EZ_SDK_VERSION "@PROJECT_VERSION@-@BUILD_NUMBER@" - -#endif diff --git a/inc/ez_version.h b/inc/ez_version.h index 11169d03..e60412e3 100644 --- a/inc/ez_version.h +++ b/inc/ez_version.h @@ -3,8 +3,8 @@ #define EZ_SDK_VERSION_MAJOR 1 #define EZ_SDK_VERSION_MINOR 0 -#define EZ_SDK_VERSION_PATCH 0 +#define EZ_SDK_VERSION_PATCH 2 #define EZ_SDK_BUILD_NUMBER 0 -#define EZ_SDK_VERSION "1.0.0-0" +#define EZ_SDK_VERSION "1.0.2-0" #endif diff --git a/inc/middlewares/osal/ez_osal.h b/inc/middlewares/osal/ez_osal.h index 0fc3fa3d..126ff1f6 100644 --- a/inc/middlewares/osal/ez_osal.h +++ b/inc/middlewares/osal/ez_osal.h @@ -78,7 +78,8 @@ extern "C" { #define EZ_OSAL_DEFINE_SEMAPHORE_HANDLE(NAME, MAX_COUNT, RESOURCE) \ ezOsal_SemaphoreHandle_t NAME = { \ .max_count = MAX_COUNT, \ - .static_resource = RESOURCE \ + .static_resource = RESOURCE, \ + .handle = NULL \ } #define EZ_OSAL_DEFINE_TIMER_HANDLE(NAME, PERIOD, FUNC, ARG, RESOURCE) \ @@ -86,12 +87,14 @@ extern "C" { .timer_name = #NAME, \ .period_ticks = PERIOD, \ .timer_callback = FUNC, \ + .handle = NULL, \ .argument = ARG, \ .static_resource = RESOURCE \ } #define EZ_OSAL_DEFINE_EVENT_HANDLE(NAME, RESOURCE) \ ezOsal_EventHandle_t NAME = { \ + .handle = NULL, \ .static_resource = RESOURCE \ } diff --git a/inc/service/cli/ez_cli.h b/inc/service/cli/ez_cli.h index 06dd7b1a..0278608c 100644 --- a/inc/service/cli/ez_cli.h +++ b/inc/service/cli/ez_cli.h @@ -87,7 +87,7 @@ typedef CLI_NOTIFY_CODE (*EXEC_CMD_CALLBACK)(char * tx_rx_buff, const void **arg * @param: None * @return one character (char) */ -typedef const char (*GET_CHAR_CALLBACK)(void); +typedef char (*GET_CHAR_CALLBACK)(void); /** @brief Callback to send response * @param[in] tx_buff: data to be transmitted diff --git a/inc/service/data_model/ez_data_model.h b/inc/service/data_model/ez_data_model.h index 11b39488..d4fe689b 100755 --- a/inc/service/data_model/ez_data_model.h +++ b/inc/service/data_model/ez_data_model.h @@ -150,7 +150,7 @@ const void* ezDataModel_GetDataPoint( * @pre data_model must be initialized using ezDataModel_Initialize() * @post None */ -const uint32_t ezDataModel_GetFirstDirty(ezDataModel_t *data_model); +uint32_t ezDataModel_GetFirstDirty(ezDataModel_t *data_model); /** diff --git a/inc/service/rpc/ez_rpc.h b/inc/service/rpc/ez_rpc.h index cbe38b94..1c5b8548 100644 --- a/inc/service/rpc/ez_rpc.h +++ b/inc/service/rpc/ez_rpc.h @@ -313,7 +313,7 @@ ezSTATUS ezRPC_CreateRpcRequest(struct ezRpc *rpc_inst, *****************************************************************************/ ezSTATUS ezRPC_CreateRpcResponse(struct ezRpc *rpc_inst, uint16_t cmd_id, - uint32_t uuid, + uint16_t uuid, uint8_t *payload, uint32_t payload_size); @@ -388,8 +388,6 @@ uint32_t ezRPC_NumOfPendingRecords(struct ezRpc *rpc_inst); *****************************************************************************/ static inline bool ezRpc_IsRpcInstanceReady(struct ezRpc *rpc_inst) { - bool is_ready = false; - if (rpc_inst != NULL) { return ((rpc_inst->commands != NULL) diff --git a/inc/utilities/hexdump/ez_hexdump.h b/inc/utilities/hexdump/ez_hexdump.h index 67effc40..badb407c 100755 --- a/inc/utilities/hexdump/ez_hexdump.h +++ b/inc/utilities/hexdump/ez_hexdump.h @@ -80,7 +80,7 @@ extern "C" { * @endcode * *****************************************************************************/ -void ezHexdump(void *address, uint16_t size); +void ezHexdump(void *address, uint32_t size); #endif /* CONFIG_HELPER_HEXDUMP */ diff --git a/inc/utilities/logging/ez_logging.h b/inc/utilities/logging/ez_logging.h index f6a4d42b..da92ee9d 100755 --- a/inc/utilities/logging/ez_logging.h +++ b/inc/utilities/logging/ez_logging.h @@ -63,25 +63,25 @@ extern "C" { #endif #if (EZ_LOGGING_COLOR == 1U) -#define black "\033[0;30m" -#define red "\033[0;31m" -#define green "\033[0;32m" -#define yellow "\033[0;33m" -#define blue "\033[0;34m" -#define purple "\033[0;35m" -#define cyan "\033[0;36m" -#define white "\033[0;37m" -#define reset_color "\033[0m" +#define EZ_BLACK "\033[0;30m" +#define EZ_RED "\033[0;31m" +#define EZ_GREEN "\033[0;32m" +#define EZ_YELLOW "\033[0;33m" +#define EZ_BLUE "\033[0;34m" +#define EZ_PURPLE "\033[0;35m" +#define EZ_CYAN "\033[0;36m" +#define EZ_WHITE "\033[0;37m" +#define EZ_RESET_COLOR "\033[0m" #else -#define black -#define red -#define green -#define yellow -#define blue -#define purple -#define cyan -#define white -#define reset_color +#define EZ_BLACK +#define EZ_RED +#define EZ_GREEN +#define EZ_YELLOW +#define EZ_BLUE +#define EZ_PURPLE +#define EZ_CYAN +#define EZ_WHITE +#define EZ_RESET_COLOR #endif #if (PRINT_MODULE_NAME == 1U) @@ -111,7 +111,7 @@ extern "C" { #if (EZ_LOGGING == 1U) #if DEBUG_LVL >= LVL_CRITICAL #define EZCRITICAL(fmt, ...) do {\ - dbg_print("\n" purple "[CRITICAL] " reset_color);\ + dbg_print("\n" EZ_PURPLE "[CRITICAL] " EZ_RESET_COLOR);\ print_module(MOD_NAME);\ print_file();\ print_line();\ @@ -124,7 +124,7 @@ extern "C" { #if DEBUG_LVL >= LVL_ERROR #define EZERROR(fmt, ...) do {\ - dbg_print("\n" red "[ ERROR] " reset_color);\ + dbg_print("\n" EZ_RED "[ ERROR] " EZ_RESET_COLOR);\ print_module(MOD_NAME);\ print_file();\ print_line();\ @@ -139,7 +139,7 @@ extern "C" { #define EZWARNING(fmt, ...) do {\ if (DEBUG_LVL >= LVL_WARNING)\ {\ - dbg_print("\n" yellow "[ WARNING] " reset_color);\ + dbg_print("\n" EZ_YELLOW "[ WARNING] " EZ_RESET_COLOR);\ print_module(MOD_NAME);\ print_file();\ print_line();\ @@ -153,7 +153,7 @@ extern "C" { #if DEBUG_LVL >= LVL_INFO #define EZINFO(fmt, ...) do {\ - dbg_print("\n" cyan "[ INFO] " reset_color);\ + dbg_print("\n" EZ_CYAN "[ INFO] " EZ_RESET_COLOR);\ print_module(MOD_NAME);\ print_file();\ print_line();\ @@ -166,7 +166,7 @@ extern "C" { #if DEBUG_LVL >= LVL_DEBUG #define EZDEBUG(fmt, ...) do {\ - dbg_print("\n" green "[ DEBUG] " reset_color);\ + dbg_print("\n" EZ_GREEN "[ DEBUG] " EZ_RESET_COLOR);\ print_module(MOD_NAME);\ print_file();\ print_line();\ @@ -180,7 +180,7 @@ extern "C" { #if DEBUG_LVL >= LVL_TRACE #define EZTRACE(fmt, ...) do {\ dbg_print("\n");\ - dbg_print(blue "[ TRACE] " reset_color);\ + dbg_print(EZ_BLUE "[ TRACE] " EZ_RESET_COLOR);\ print_module(MOD_NAME);\ print_file();\ print_line();\ diff --git a/samples/linux/main.c b/samples/linux/main.c index 833d4867..ba4d77f8 100755 --- a/samples/linux/main.c +++ b/samples/linux/main.c @@ -59,10 +59,11 @@ * External functions *******************************************************************************/ -void main(void) +int main(void) { printf("Linux target - Hello world!\n"); printf("Version: %s\n", EZ_SDK_VERSION); + return 0; } /****************************************************************************** diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e83874f..0cef5bd2 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,28 @@ message(STATUS "**********************************************************") message(STATUS "* Generating easy_embedded library build files") message(STATUS "**********************************************************") +# GCC/Clang quality and security flags for framework targets only +if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + add_compile_options( + -Wall + -Wextra + -Wpedantic + -Werror + -Wconversion + -Wshadow + -Wformat=2 + -Wnull-dereference + -Wduplicated-cond + -Wduplicated-branches + -Wlogical-op + -Wcast-align + ) + + add_compile_definitions( + $<$:_FORTIFY_SOURCE=2> + ) +endif() + option(BUILD_WITH_CMAKE "code base is built using CMake. Do not turn this OFF" ON) # Include -------------------------------------------------------------------- diff --git a/src/hal/gpio/ez_gpio.c b/src/hal/gpio/ez_gpio.c index f7ddb516..1052e6e0 100644 --- a/src/hal/gpio/ez_gpio.c +++ b/src/hal/gpio/ez_gpio.c @@ -60,8 +60,6 @@ static struct Node hw_driver_list = EZ_LINKEDLIST_INIT_NODE(hw_driver_list); *****************************************************************************/ EZ_DRV_STATUS ezGpio_SystemRegisterHwDriver(struct ezGpioDriver *hw_gpio_driver) { - EZ_DRV_STATUS status = STATUS_ERR_GENERIC; - EZTRACE("ezGpio_SystemRegisterHwDriver()"); if(hw_gpio_driver == NULL) { diff --git a/src/hal/uart/ez_uart.c b/src/hal/uart/ez_uart.c index 57024bba..69b1aa75 100644 --- a/src/hal/uart/ez_uart.c +++ b/src/hal/uart/ez_uart.c @@ -435,6 +435,8 @@ static void ezUart_PrintStatus(EZ_DRV_STATUS status) case STATUS_TIMEOUT: EZDEBUG("STATUS_TIMEOUT"); break; default: break; } +#else + (void)status; /* avoid unused parameter warning */ #endif } diff --git a/src/middlewares/osal/CMakeLists.txt b/src/middlewares/osal/CMakeLists.txt index fed9bece..499d0209 100644 --- a/src/middlewares/osal/CMakeLists.txt +++ b/src/middlewares/osal/CMakeLists.txt @@ -23,6 +23,14 @@ target_sources(ez_osal_lib $<$:ez_osal_threadx.c> ) +if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") + set_source_files_properties( + ez_osal_threadx.c + PROPERTIES + COMPILE_OPTIONS "-Wno-error=cast-function-type" + ) +endif() + # Definitions ---------------------------------------------------------------- target_compile_definitions(ez_osal_lib diff --git a/src/middlewares/osal/ez_osal_freertos.c b/src/middlewares/osal/ez_osal_freertos.c index 33e6c8ef..59e4caf7 100644 --- a/src/middlewares/osal/ez_osal_freertos.c +++ b/src/middlewares/osal/ez_osal_freertos.c @@ -428,11 +428,11 @@ static int ezOsal_FreeRTOSEventWait(ezOsal_EventHandle_t *handle, uint32_t event if((bits & event_mask) > 0) { EZDEBUG("event is set"); - return bits; + return (int)bits; } EZWARNING("Event = %d timeout", event_mask); - return bits; + return (int)bits; } static ezSTATUS ezOsal_FreeRTOSEventSet(ezOsal_EventHandle_t *handle, uint32_t event_mask) @@ -471,6 +471,7 @@ static ezSTATUS ezOsal_FreeRTOSEventClear(ezOsal_EventHandle_t *handle, uint32_t EZDEBUG("Clear event mask = %d", event_mask); bits = xEventGroupClearBits((EventGroupHandle_t)handle->handle, event_mask); EZDEBUG("Clear event success"); + (void)bits; return ezSUCCESS; } diff --git a/src/middlewares/osal/ez_osal_threadx.c b/src/middlewares/osal/ez_osal_threadx.c index 57783d54..54a6e443 100644 --- a/src/middlewares/osal/ez_osal_threadx.c +++ b/src/middlewares/osal/ez_osal_threadx.c @@ -255,7 +255,7 @@ static ezSTATUS ezOsal_ThreadXTaskResume(ezOsal_TaskHandle_t *task_handle) static ezSTATUS ezOsal_ThreadXTaskDelay(unsigned long num_of_ticks) { - tx_thread_sleep(num_of_ticks); + tx_thread_sleep((ULONG)num_of_ticks); return ezSUCCESS; } @@ -498,7 +498,7 @@ static int ezOsal_ThreadXOSEventWait( return 0; } - return actual_events; + return (int)actual_events; } @@ -579,6 +579,8 @@ static void ezOsal_ThreadXPrintStatusCode(UINT code) case TX_NO_INSTANCE: EZERROR("TX_NO_INSTANCE "); break; default: EZERROR("Unsupported code, %d", code); break; } +#else + (void)code; #endif } diff --git a/src/service/cli/ez_cli.c b/src/service/cli/ez_cli.c index 001ae19f..a879a5a1 100644 --- a/src/service/cli/ez_cli.c +++ b/src/service/cli/ez_cli.c @@ -234,14 +234,14 @@ static void ezCli_HandleStateArgument(ezCli_t *self, const char c) self->arg_list[self->curr_arg_index]) == false) { /* argument is not existing, return error */ - EZDEBUG("[arg = %s] is not supported", self->arg_list[self->curr_arg_index]); + EZDEBUG("[arg = %s] is not supported", (char*)self->arg_list[self->curr_arg_index]); ezCli_PrintCommandHelper(self, &self->cmd_list->commands[self->curr_cmd_index]); self->state = STATE_ERROR; return; } else { - EZDEBUG("complete parse the argument: [arg = %s]", self->arg_list[self->curr_arg_index]); + EZDEBUG("complete parse the argument: [arg = %s]", (char*)self->arg_list[self->curr_arg_index]); self->is_arg_found = false; self->state = STATE_VALUE; } @@ -300,7 +300,7 @@ static void ezCli_HandleStateValue(ezCli_t *self, const char c) /* complete parse the argument*/ self->cli_buffer->buff[self->cli_buffer->curr_index] = STR_TERMINATE; self->cli_buffer->curr_index++; - EZDEBUG("complete parse the value: [value = %s]", self->value_list[self->curr_arg_index]); + EZDEBUG("complete parse the value: [value = %s]", (char*)self->value_list[self->curr_arg_index]); self->quotation_mark_count = 0; self->is_value_found = false; self->curr_arg_index++; @@ -333,10 +333,10 @@ static void ezCli_HandleStateValue(ezCli_t *self, const char c) if(self->quotation_mark_count == 1) { EZDEBUG("String starts"); - self->is_value_found == true; + self->is_value_found = true; /* Automatically increase index by 1 to bypass the " and store the next char */ - self->value_list[self->curr_arg_index] = (void*)&self->cli_buffer->buff[self->cli_buffer->curr_index + 1]; + self->value_list[self->curr_arg_index] = (void*)&self->cli_buffer->buff[self->cli_buffer->curr_index]; } else if (self->quotation_mark_count == 2) { @@ -357,10 +357,10 @@ static void ezCli_HandleStateValue(ezCli_t *self, const char c) self->cli_buffer->curr_index++; self->quotation_mark_count = 0; self->is_value_found = false; + EZDEBUG("complete parse the value: [value = %s]", (char*)self->value_list[self->curr_arg_index]); self->curr_arg_index++; ezCli_ProcessCommand(self); self->state = STATE_COMMAND; - EZDEBUG("complete parse the value: [value = %s]", self->value_list[self->curr_arg_index]); } else { @@ -421,7 +421,7 @@ static void ezCli_ProcessCommand(ezCli_t *self) if(ret == CLI_NC_OK) { EZDEBUG("execute command successfully"); - self->interface->SendCharsCallback(self->cli_buffer->buff, strlen(self->cli_buffer->buff)); + self->interface->SendCharsCallback(self->cli_buffer->buff, (uint16_t)strlen(self->cli_buffer->buff)); } else if(ret == CLI_NC_BAD_ARG) { @@ -550,7 +550,6 @@ static bool ezCli_IsArgumentExisting( ezCliCommand_t *cmd, const char * arg) { - uint8_t index = ARG_INVALID; for(uint8_t i = 0; i < CONFIG_NUM_OF_ARGUMENT; i++) { if(cmd->long_arg_list[i] != NULL && @@ -579,7 +578,7 @@ static void ezCli_Printf (ezCli_t *self, char* fmt, ...) va_start(args, fmt); vsnprintf(self->cli_buffer->buff, self->cli_buffer->size, fmt, args); va_end(args); - self->interface->SendCharsCallback(self->cli_buffer->buff, self->cli_buffer->size); + self->interface->SendCharsCallback(self->cli_buffer->buff, (uint16_t)self->cli_buffer->size); } #endif /* EZ_CLI == 1 */ diff --git a/src/service/data_model/ez_data_model.c b/src/service/data_model/ez_data_model.c index 39396fb7..97e003e6 100755 --- a/src/service/data_model/ez_data_model.c +++ b/src/service/data_model/ez_data_model.c @@ -50,6 +50,7 @@ /***************************************************************************** * Component Variable Definitions +*****************************************************************************/ /* None */ @@ -214,7 +215,7 @@ void ezDataModel_ClearAllDirtyFlags(ezDataModel_t *data_model) } -const uint32_t ezDataModel_GetFirstDirty(ezDataModel_t *data_model) +uint32_t ezDataModel_GetFirstDirty(ezDataModel_t *data_model) { uint32_t dirty_index = DATA_POINT_INVALID; @@ -251,14 +252,13 @@ static bool ezDataModel_AllocateDataPoints(ezDataModel_t *data_model) size_t remain_byte = data_model->data_model_buff_size; uint32_t current_index = data_model->data_points[0].index; uint8_t *current_buff_ptr = data_model->data_model_buff; - size_t required_size = 0; for(size_t i = 0U; i < data_model->num_of_data_points; i++) { if (i > 0) { ASSERT_CUST_MSG(current_index < data_model->data_points[i].index, - "current index (%lu) > data point index (%lu)", + "current index (%d) > data point index (%d)", current_index, data_model->data_points[i].index); } @@ -266,7 +266,7 @@ static bool ezDataModel_AllocateDataPoints(ezDataModel_t *data_model) ASSERT_CUST_MSG(data_model->data_points[i].size > 0, "data point size is zero"); ASSERT_CUST_MSG(data_model->data_points[i].size <= remain_byte, - "required size (%lu) > remain byte (%lu)", + "required size (%d) > remain byte (%d)", data_model->data_points[i].size, remain_byte); diff --git a/src/service/event_bus/ez_event_bus.c b/src/service/event_bus/ez_event_bus.c index 303528ef..527c4613 100755 --- a/src/service/event_bus/ez_event_bus.c +++ b/src/service/event_bus/ez_event_bus.c @@ -67,7 +67,6 @@ ezSTATUS ezEventBus_CreateBus( uint32_t buff_size) { EZDEBUG("evntNoti_CreateSubject()"); - ezSTATUS status = ezFAIL; if(buff == NULL || buff_size == 0U || event_bus == NULL) { @@ -274,7 +273,7 @@ bool ezEventBus_SendEvent( q_element_event_code = ezQueue_ReserveElement(&event_bus->event_queue, &code, sizeof(uint32_t)); - q_element_data = ezQueue_ReserveElement(&event_bus->event_queue, &data, event_data_size); + q_element_data = ezQueue_ReserveElement(&event_bus->event_queue, &data, (uint32_t)event_data_size); if(q_element_event_code == NULL || q_element_data == NULL) { diff --git a/src/service/ipc/ez_ipc.c b/src/service/ipc/ez_ipc.c index 74ea89e3..e186db94 100644 --- a/src/service/ipc/ez_ipc.c +++ b/src/service/ipc/ez_ipc.c @@ -63,6 +63,8 @@ /***************************************************************************** * Component Typedefs +*****************************************************************************/ + /**@brief structure define an IPC instance * */ diff --git a/src/service/rpc/ez_rpc.c b/src/service/rpc/ez_rpc.c index bdbe33fb..466e5ae2 100644 --- a/src/service/rpc/ez_rpc.c +++ b/src/service/rpc/ez_rpc.c @@ -138,7 +138,7 @@ ezSTATUS ezRpc_Initialization(struct ezRpc *rpc_inst, if (status == ezSUCCESS) { rpc_inst->commands = commands; - rpc_inst->num_of_commands = num_of_commands; + rpc_inst->num_of_commands = (uint16_t)num_of_commands; rpc_inst->unmarshal.state = STATE_SYNC; rpc_inst->unmarshal.byte_count = 0; @@ -223,7 +223,7 @@ ezSTATUS ezRPC_CreateRpcRequest(struct ezRpc *rpc_inst, ezSTATUS ezRPC_CreateRpcResponse(struct ezRpc *rpc_inst, uint16_t cmd_id, - uint32_t uuid, + uint16_t uuid, uint8_t *payload, uint32_t payload_size) { @@ -252,7 +252,6 @@ ezSTATUS ezRPC_CreateRpcResponse(struct ezRpc *rpc_inst, void ezRPC_Run(struct ezRpc *rpc_inst) { - ezSTATUS status = ezSUCCESS; uint8_t one_byte = 0U; uint8_t *req = NULL; uint32_t req_size = 0U; @@ -363,18 +362,18 @@ static ezSTATUS ezRpc_MarshalHeader(uint8_t *buff, *(buff++) = (SYNC_BYTES >> 8); *(buff++) = (SYNC_BYTES & 0xFF); - *(buff++) = (header->uuid >> 8); - *(buff++) = (header->uuid & 0xFF); + *(buff++) = (uint8_t)(header->uuid >> 8); + *(buff++) = (uint8_t)(header->uuid & 0xFF); *(buff++) = (uint8_t)header->type; *(buff++) = header->is_encrypted; - *(buff++) = (header->cmd_id >> 8); - *(buff++) = (header->cmd_id & 0xFF); + *(buff++) = (uint8_t)(header->cmd_id >> 8); + *(buff++) = (uint8_t)(header->cmd_id & 0xFF); - *(buff++) = (header->payload_size >24); - *(buff++) = ((header->payload_size >> 16 & 0xFF)); - *(buff++) = ((header->payload_size >>8) & 0xFF); - *(buff++) = (header->payload_size & 0xFF); + *(buff++) = (uint8_t)(header->payload_size >> 24); + *(buff++) = (uint8_t)((header->payload_size >> 16) & 0xFF); + *(buff++) = (uint8_t)((header->payload_size >> 8) & 0xFF); + *(buff++) = (uint8_t)(header->payload_size & 0xFF); return ezSUCCESS; } return ezFAIL; @@ -442,8 +441,6 @@ static struct ezRpcRequestRecord *ezRpc_GetAvailRecord(struct ezRpc *rpc_inst) *******************************************************************************/ static void ezRpc_UnmarshalData(struct ezRpc *rpc_inst, uint8_t rx_byte) { - ezSTATUS status = ezSUCCESS; - if (rpc_inst != NULL) { switch (rpc_inst->unmarshal.state) @@ -643,11 +640,11 @@ static void ezRpc_UnmarshalData(struct ezRpc *rpc_inst, uint8_t rx_byte) } else { - status = ezQueue_PushReservedElement( + (void)ezQueue_PushReservedElement( &rpc_inst->rx_msg_queue, rpc_inst->unmarshal.header_elem); - status = ezQueue_PushReservedElement( + (void)ezQueue_PushReservedElement( &rpc_inst->rx_msg_queue, rpc_inst->unmarshal.payload_elem); @@ -676,11 +673,11 @@ static void ezRpc_UnmarshalData(struct ezRpc *rpc_inst, uint8_t rx_byte) rpc_inst->crc_handler->size) == true) { EZDEBUG("crc correct"); - status = ezQueue_PushReservedElement( + (void)ezQueue_PushReservedElement( &rpc_inst->rx_msg_queue, rpc_inst->unmarshal.header_elem); - status = ezQueue_PushReservedElement( + (void)ezQueue_PushReservedElement( &rpc_inst->rx_msg_queue, rpc_inst->unmarshal.payload_elem); } @@ -1006,7 +1003,7 @@ void ezRpc_PrintHeader(struct ezRpcMsgHeader *header) dbg_print("type:\t\t unknown\n"); } - dbg_print("tag:\t\t %d\n", header->tag); + dbg_print("cmd id:\t\t %d\n", header->cmd_id); dbg_print("encrypt:\t %d\n", header->is_encrypted); dbg_print("size:\t\t %d\n", header->payload_size); dbg_print("\n"); diff --git a/src/service/state_machine/ez_state_machine.c b/src/service/state_machine/ez_state_machine.c index 72e15b95..3565eef8 100644 --- a/src/service/state_machine/ez_state_machine.c +++ b/src/service/state_machine/ez_state_machine.c @@ -71,7 +71,7 @@ bool ezSM_Init(ezStateMachine_t *sm, && (NULL != event_buff) && (event_buff_size > 0)) { - success = ezRingBuffer_Init(&sm->events, event_buff, event_buff_size); + success = ezRingBuffer_Init(&sm->events, event_buff, (uint16_t)event_buff_size); if(false == success) { EZERROR(" init ring buffer error"); diff --git a/src/service/task_worker/ez_task_worker.c b/src/service/task_worker/ez_task_worker.c index a5f280ff..c6d9f9c9 100644 --- a/src/service/task_worker/ez_task_worker.c +++ b/src/service/task_worker/ez_task_worker.c @@ -65,8 +65,6 @@ struct ezTaskBlockCommon * Component Variable Definitions *****************************************************************************/ static struct Node worker_list = EZ_LINKEDLIST_INIT_NODE(worker_list); -static struct ezTaskWorkerThreadInterfaces *rtos_interfaces = NULL; - /***************************************************************************** * Function Definitions *****************************************************************************/ @@ -80,7 +78,6 @@ bool ezTaskWorker_CreateWorker(struct ezTaskWorker *worker, { EZTRACE("ezTaskWorker_CreateWorker()"); ezSTATUS status = ezFAIL; - if(worker != NULL) { #if ((EZ_FREERTOS_PORT == 1) || (EZ_THREADX_PORT == 1)) @@ -108,6 +105,7 @@ bool ezTaskWorker_CreateWorker(struct ezTaskWorker *worker, } } #else + (void)status; ezLinkedList_InitNode(&worker->node); if( EZ_LINKEDLIST_ADD_TAIL(&worker_list, &worker->node) == false) { @@ -151,6 +149,8 @@ bool ezTaskWorker_EnqueueTask(struct ezTaskWorker *worker, { ret = false; } + #else + (void)ticks_to_wait; #endif /* (EZ_OSAL == 1) */ if(ret == true) @@ -171,7 +171,7 @@ bool ezTaskWorker_EnqueueTask(struct ezTaskWorker *worker, ((struct ezTaskBlockCommon*)buff)->task = task; /* Offset the pointer */ - buff += sizeof(struct ezTaskBlockCommon); + buff = (char*)buff + sizeof(struct ezTaskBlockCommon); /* Copy context data */ memcpy(buff, context, context_size); @@ -245,7 +245,7 @@ void ezTaskWorker_ExecuteTask(struct ezTaskWorker *worker, uint32_t ticks_to_wai if((status == ezSUCCESS) && (common->task != NULL)) { context = common; - context += sizeof(struct ezTaskBlockCommon); + context = (char*)context + sizeof(struct ezTaskBlockCommon); common->task(context, common->callback); status = ezQueue_PopFront(&worker->msg_queue); } @@ -279,7 +279,7 @@ void ezTaskWorker_ExecuteTaskNoRTOS(void) if(status == ezSUCCESS && common->task != NULL) { context = common; - context += sizeof(struct ezTaskBlockCommon); + context = (char*)context + sizeof(struct ezTaskBlockCommon); common->task(context, common->callback); } status = ezQueue_PopFront(&worker->msg_queue); diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index 5ee21d43..be893ab5 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -17,7 +17,6 @@ set(FRAMEWORK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) # Source files --------------------------------------------------------------- target_sources(ez_utilities_lib PRIVATE - assert/ez_assert.c hexdump/ez_hexdump.c linked_list/ez_linked_list.c logging/ez_logging.c diff --git a/src/utilities/assert/ez_assert.c b/src/utilities/assert/ez_assert.c deleted file mode 100755 index a25d8e74..00000000 --- a/src/utilities/assert/ez_assert.c +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** -* Filename: ez_assert.c -* Author: Hai Nguyen -* Original Date: 18.02.2024 -* -* ---------------------------------------------------------------------------- -* Contact: Hai Nguyen -* hainguyen.eeit@gmail.com -* -* ---------------------------------------------------------------------------- -* License: This file is published under the license described in LICENSE.md -* -*****************************************************************************/ - -/** @file ez_assert.c - * @author Hai Nguyen - * @date 18.02.2024 - * @brief Implementation of the assert component - * - * @details No implementation - * - */ - - -/****************************************************************************** -* Includes -*******************************************************************************/ -#if (EZ_ASSERT == 1U) -/* None */ - -/****************************************************************************** -* Module Typedefs -*******************************************************************************/ -/* None */ - - -/****************************************************************************** -* Module Variable Definitions -*******************************************************************************/ -/* None */ - - -/****************************************************************************** -* Function Definitions -*******************************************************************************/ -/* None */ - -#endif /* CONFIG_HELPER_ASSERT */ - -/* End of file*/ diff --git a/src/utilities/hexdump/ez_hexdump.c b/src/utilities/hexdump/ez_hexdump.c index e8fdaa4a..919f20f0 100755 --- a/src/utilities/hexdump/ez_hexdump.c +++ b/src/utilities/hexdump/ez_hexdump.c @@ -57,39 +57,41 @@ static void PrintAscii(char c); /***************************************************************************** * External functions *****************************************************************************/ -void ezHexdump( void *address, uint16_t size) +void ezHexdump( void *address, uint32_t size) { void * ulStartingAddress = address; - - dbg_print("\n\nAddress: %p - size: %d\n", address, size); - dbg_print("00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n"); + dbg_print("\n"); + dbg_print(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n"); while((uint8_t*)ulStartingAddress < (uint8_t*)address + size) { + dbg_print("%p: ", ulStartingAddress); for(uint8_t i = 0; i < 16; i = i + 1) { - if((uint8_t *)((uint8_t*)ulStartingAddress + i) - (uint8_t *) address < size) + if((uint8_t*)ulStartingAddress + i < (uint8_t*)address + size) { dbg_print("%02x ", *((uint8_t*)ulStartingAddress + i)); } else { - dbg_print("%s"," "); + dbg_print("%s", " "); } } dbg_print("%s", "| "); for(uint8_t i = 0; i < 16; i = i + 1) { - if ((uint8_t*)((uint8_t*)ulStartingAddress + i) - (uint8_t*)address < size) + if((uint8_t*)ulStartingAddress + i < (uint8_t*)address + size) { PrintAscii(*(char*)((uint8_t*)ulStartingAddress + i)); } + else + { + dbg_print("%s", " "); + } } - dbg_print("\n"); ulStartingAddress = (uint8_t*)ulStartingAddress + 16; } - dbg_print(""); } @@ -103,7 +105,7 @@ void ezHexdump( void *address, uint16_t size) * @brief Print readable ascii value * @details Non-readable ascii will be printed as a dot "." * -* @param c: (IN)ascci will be printed +* @param c: (IN)ascii character will be printed * @return None * * @pre None @@ -118,7 +120,7 @@ void ezHexdump( void *address, uint16_t size) static void PrintAscii(char c) { /* Only print readable ascii character */ - if (c >= 33U && c <= 126U) + if (c >= 0x20 && c <= 0x7E) { dbg_print("%c", c); } diff --git a/src/utilities/queue/ez_queue.c b/src/utilities/queue/ez_queue.c index 858cd2f2..31e89b51 100755 --- a/src/utilities/queue/ez_queue.c +++ b/src/utilities/queue/ez_queue.c @@ -20,8 +20,6 @@ * @details */ -/***************************************************************************** - /***************************************************************************** * Includes *****************************************************************************/ @@ -75,14 +73,14 @@ ezSTATUS ezQueue_CreateQueue(ezQueue *queue, uint8_t *buff, uint32_t buff_size) { ezSTATUS status = ezFAIL; - EZTRACE("ezQueue_CreateQueue( size = %lu)", buff_size); + EZTRACE("ezQueue_CreateQueue( size = %d)", buff_size); memset(buff, 0, buff_size); if (queue != NULL && buff != NULL && buff_size > 0) { ezLinkedList_InitNode(&queue->q_item_list); - if (ezStaticAlloc_InitMemList(&queue->mem_list, buff, buff_size) == true) + if (ezStaticAlloc_InitMemList(&queue->mem_list, buff, (uint16_t)buff_size) == true) { status = ezSUCCESS; EZDEBUG("create queue success"); @@ -174,7 +172,7 @@ ezReservedElement ezQueue_ReserveElement(ezQueue *queue, void **data, uint32_t d { ezQueueItem* item = NULL; - EZTRACE("ezQueue_Push( [@ = %p], [size = %lu])", data, data_size); + EZTRACE("ezQueue_Push( [@ = %p], [size = %d])", *data, data_size); if (queue != NULL && data != NULL && data_size > 0) { @@ -183,7 +181,7 @@ ezReservedElement ezQueue_ReserveElement(ezQueue *queue, void **data, uint32_t d if (item != NULL) { item->data_size = data_size; - item->data = ezStaticAlloc_Malloc(&queue->mem_list, data_size); + item->data = ezStaticAlloc_Malloc(&queue->mem_list, (uint16_t)data_size); if (item->data == NULL) { @@ -244,7 +242,7 @@ ezSTATUS ezQueue_Push(ezQueue* queue, void *data, uint32_t data_size) void *reserve_data = NULL; ezReservedElement reserved_elem = NULL; - EZTRACE("ezQueue_Push( [@ = %p], [size = %lu])", data, data_size); + EZTRACE("ezQueue_Push( [@ = %p], [size = %d])", data, data_size); if (queue != NULL && data != NULL && data_size > 0) { @@ -287,10 +285,10 @@ ezSTATUS ezQueue_GetFront(ezQueue* queue, void **data, uint32_t *data_size) #if (DEBUG_LVL == LVL_TRACE) EZTRACE("[item address = %p]", (void*)front_item); EZTRACE("[item node address = %p]", (void*)&front_item->node); - EZTRACE("[item data size = %p]", (void*)front_item->data_size); + EZTRACE("[item data size = %d]", front_item->data_size); EZTRACE("data of front item"); - EZHEXDUMP((uint8_t*)*data, *data_size); + EZHEXDUMP((uint8_t*)*data, (uint16_t)*data_size); #endif /* DEBUG_LVL == LVL_TRACE */ } else @@ -325,7 +323,7 @@ ezSTATUS ezQueue_GetBack(ezQueue* queue, void **data, uint32_t *data_size) #if (DEBUG_LVL == LVL_TRACE) EZTRACE("data of back item"); - EZHEXDUMP((uint8_t*)*data, *data_size); + EZHEXDUMP((uint8_t*)*data, (uint16_t)*data_size); #endif } else diff --git a/tests/service/cli/unittest_ez_cli.c b/tests/service/cli/unittest_ez_cli.c index 3952c067..2d09fa21 100644 --- a/tests/service/cli/unittest_ez_cli.c +++ b/tests/service/cli/unittest_ez_cli.c @@ -404,6 +404,7 @@ static void SendCharsCallback(char *tx_buff, uint16_t size) static CLI_NOTIFY_CODE ExecuteOneArgumentCallback(char * tx_rx_buff, const void **arg_list, const void **value_list) { + (void)arg_list; is_one_arg_cmd_executed = true; TEST_ASSERT_EQUAL_STRING("value1", value_list[0]); sprintf(tx_rx_buff, "test completed\n"); @@ -412,6 +413,7 @@ static CLI_NOTIFY_CODE ExecuteOneArgumentCallback(char * tx_rx_buff, const void static CLI_NOTIFY_CODE ExecuteTwoArgumentsCallback(char * tx_rx_buff, const void **arg_list, const void **value_list) { + (void)arg_list; is_two_arg_cmd_executed = true; TEST_ASSERT_EQUAL_STRING("value1", value_list[0]); TEST_ASSERT_EQUAL_STRING("value2", value_list[1]); @@ -421,6 +423,7 @@ static CLI_NOTIFY_CODE ExecuteTwoArgumentsCallback(char * tx_rx_buff, const void static CLI_NOTIFY_CODE ExecuteTwoArgumentsButFirstOnlyCallback(char * tx_rx_buff, const void **arg_list, const void **value_list) { + (void)arg_list; is_two_arg_cmd_executed = true; TEST_ASSERT_EQUAL_STRING("value1", value_list[0]); TEST_ASSERT_NULL(value_list[1]); @@ -431,6 +434,7 @@ static CLI_NOTIFY_CODE ExecuteTwoArgumentsButFirstOnlyCallback(char * tx_rx_buff static CLI_NOTIFY_CODE ExecuteTwoArgumentsButSecondOnlyCallback(char * tx_rx_buff, const void **arg_list, const void **value_list) { + (void)arg_list; TEST_ASSERT_EQUAL_STRING("value2", value_list[0]); is_two_arg_cmd_executed = true; TEST_ASSERT_NULL(value_list[1]); @@ -440,10 +444,11 @@ static CLI_NOTIFY_CODE ExecuteTwoArgumentsButSecondOnlyCallback(char * tx_rx_buf static CLI_NOTIFY_CODE ExecutesStringArgumentsCallback(char * tx_rx_buff, const void **arg_list, const void **value_list) { + (void)arg_list; TEST_ASSERT_EQUAL_STRING(input_string, value_list[0]); is_string_executed = true; TEST_ASSERT_NULL(value_list[1]); - sprintf(tx_rx_buff, "%s\n", value_list[0]); + sprintf(tx_rx_buff, "%s\n", (char*)value_list[0]); return CLI_NC_OK; } diff --git a/tests/service/datamodel/unittest_ez_datamodel.cpp b/tests/service/datamodel/unittest_ez_datamodel.cpp index d54076be..1645c3a7 100644 --- a/tests/service/datamodel/unittest_ez_datamodel.cpp +++ b/tests/service/datamodel/unittest_ez_datamodel.cpp @@ -55,20 +55,19 @@ * Module Typedefs *******************************************************************************/ static uint8_t buff[BUFFER_SIZE]; -static uint8_t event_buff[BUFFER_SIZE]; static ezDataPoint_t data_points[] = { - {DATA_POINT_BOOL_IDX, sizeof(bool), NULL}, - {DATA_POINT_UINT8_IDX, sizeof(uint8_t), NULL}, - {DATA_POINT_UINT16_IDX, sizeof(uint16_t), NULL}, - {DATA_POINT_UINT32_IDX, sizeof(uint32_t), NULL}, - {DATA_POINT_INT8_IDX, sizeof(int8_t), NULL}, - {DATA_POINT_INT16_IDX, sizeof(int16_t), NULL}, - {DATA_POINT_INT32_IDX, sizeof(int32_t), NULL}, - {DATA_POINT_FLOAT_IDX, sizeof(float), NULL}, - {DATA_POINT_DOUBLE_IDX, sizeof(double), NULL}, - {DATA_POINT_STRING_IDX, DATA_POINT_STRING_SIZE, NULL}, - {DATA_POINT_BLOB_IDX, DATA_POINT_BLOB_SIZE, NULL}, + {DATA_POINT_BOOL_IDX, sizeof(bool), NULL, false}, + {DATA_POINT_UINT8_IDX, sizeof(uint8_t), NULL, false}, + {DATA_POINT_UINT16_IDX, sizeof(uint16_t), NULL, false}, + {DATA_POINT_UINT32_IDX, sizeof(uint32_t), NULL, false}, + {DATA_POINT_INT8_IDX, sizeof(int8_t), NULL, false}, + {DATA_POINT_INT16_IDX, sizeof(int16_t), NULL, false}, + {DATA_POINT_INT32_IDX, sizeof(int32_t), NULL, false}, + {DATA_POINT_FLOAT_IDX, sizeof(float), NULL, false}, + {DATA_POINT_DOUBLE_IDX, sizeof(double), NULL, false}, + {DATA_POINT_STRING_IDX, DATA_POINT_STRING_SIZE, NULL, false}, + {DATA_POINT_BLOB_IDX, DATA_POINT_BLOB_SIZE, NULL, false}, }; class DatamodelTestsFixture { @@ -267,7 +266,7 @@ TEST_CASE_METHOD(DatamodelTestsFixture, "Data is not overflown", "[service][data WHEN("Data is set") { - ezSTATUS status = ezDataModel_SetDataPoint( + status = ezDataModel_SetDataPoint( &data_model, DATA_POINT_BOOL_IDX, &bool_value); diff --git a/tests/service/driver/uart/unittest_ez_uart.c b/tests/service/driver/uart/unittest_ez_uart.c index aa9d2273..c88c7d7d 100644 --- a/tests/service/driver/uart/unittest_ez_uart.c +++ b/tests/service/driver/uart/unittest_ez_uart.c @@ -494,19 +494,23 @@ static void RunAllTests(void) static EZ_DRV_STATUS ezMockUart_Initialize(uint8_t index) { + (void)index; return STATUS_OK; } static EZ_DRV_STATUS ezMockUart_Deinitialize(uint8_t index) { + (void)index; return STATUS_OK; } static EZ_DRV_STATUS ezMockUart_AsyncTransmit(uint8_t index, const uint8_t *tx_buff, uint16_t buff_size) { - /* In reality, the HW driver declare the ezUartDriver, so it has access to this struct */ + (void)index; + (void)tx_buff; + (void)buff_size; if(mock_hw.common.curr_inst != NULL && mock_hw.common.curr_inst->calback != NULL) { mock_hw.common.curr_inst->calback(UART_EVENT_TX_CMPLT, NULL, NULL); @@ -520,6 +524,9 @@ static EZ_DRV_STATUS ezMockUart_AsyncTransmit(uint8_t index, const uint8_t *tx_b static EZ_DRV_STATUS ezMockUart_AsyncReceive(uint8_t index, uint8_t *rx_buff, uint16_t buff_size) { + (void)index; + (void)rx_buff; + (void)buff_size; /* In reality, the HW driver declare the ezUartDriver, so it has access to this struct */ if(mock_hw.common.curr_inst != NULL && mock_hw.common.curr_inst->calback != NULL) { @@ -534,18 +541,27 @@ static EZ_DRV_STATUS ezMockUart_AsyncReceive(uint8_t index, uint8_t *rx_buff, ui static EZ_DRV_STATUS ezMockUart_SyncTransmit(uint8_t index, const uint8_t *tx_buff, uint16_t buff_size, uint32_t timeout_millis) { + (void)index; + (void)tx_buff; + (void)buff_size; + (void)timeout_millis; return STATUS_OK; } static EZ_DRV_STATUS ezMockUart_SyncReceive(uint8_t index, uint8_t *rx_buff, uint16_t buff_size, uint32_t timeout_millis) { + (void)index; + (void)rx_buff; + (void)buff_size; + (void)timeout_millis; return STATUS_OK; } static EZ_DRV_STATUS ezMockUart_UpdateConfig(uint8_t index) { + (void)index; return STATUS_OK; } @@ -567,6 +583,8 @@ static void ezMockUart_SetImplementedInterface(struct ezHwUartInterface *interfa static void ezMockUart_Callback(uint8_t event_code, void *param1, void *param2) { + (void)param1; + (void)param2; uart_event = (EZ_UART_EVENT)event_code; } diff --git a/tests/service/event_bus/unittest_ez_event_bus.c b/tests/service/event_bus/unittest_ez_event_bus.c index 25b03068..7c25b793 100644 --- a/tests/service/event_bus/unittest_ez_event_bus.c +++ b/tests/service/event_bus/unittest_ez_event_bus.c @@ -45,7 +45,7 @@ TEST_GROUP(ez_event_bus); *******************************************************************************/ typedef struct{ int a; - int b;; + int b; }TestData_t; diff --git a/tests/service/rpc/unittest_ez_rpc.cpp b/tests/service/rpc/unittest_ez_rpc.cpp index 964f51c5..202c89fd 100644 --- a/tests/service/rpc/unittest_ez_rpc.cpp +++ b/tests/service/rpc/unittest_ez_rpc.cpp @@ -284,6 +284,9 @@ RpcTestFixture::RpcTestFixture() void ClientSum(struct ezRpcMsgHeader *header, void *payload, uint32_t payload_size_byte) { + (void)header; + (void)payload_size_byte; + (void)payload; client_func_called = true; sum_val = *(uint32_t*)payload; sum_val = EZNTOH32(sum_val); @@ -292,6 +295,7 @@ void ClientSum(struct ezRpcMsgHeader *header, void *payload, uint32_t payload_si void ServerSum(struct ezRpcMsgHeader *header, void *payload, uint32_t payload_size_byte) { + (void)payload_size_byte; uint8_t *arg = (uint8_t*)payload; uint32_t a = *(uint32_t *)arg; arg += 4; @@ -399,6 +403,7 @@ void CalculateCrC( void ServerErrorCallback(RPC_ERROR error_code, void *context) { + (void)context; last_server_error = error_code; } diff --git a/tests/service/state_machine/unittest_ez_state_machine.c b/tests/service/state_machine/unittest_ez_state_machine.c index 1bfd45a7..fb914a85 100644 --- a/tests/service/state_machine/unittest_ez_state_machine.c +++ b/tests/service/state_machine/unittest_ez_state_machine.c @@ -80,18 +80,21 @@ static void RunAllTests(void); DEFINE_ACTION_FUNCTION(Receive) { + (void)sm; receive_action_count++; return NULL; } DEFINE_ENTRY_FUNCTION(Receive) { + (void)sm; receive_enter_count++; return NULL; } DEFINE_EXIT_FUNCTION(Receive) { + (void)sm; receive_exit_count++; return NULL; } @@ -119,26 +122,31 @@ DEFINE_EVENT_HANDLER_FUNCTION(Receive) DEFINE_ACTION_FUNCTION(Transmit) { + (void)sm; transmit_action_count++; ezState_t *state = &Receive; + (void)state; return NULL; } DEFINE_ENTRY_FUNCTION(Transmit) { + (void)sm; transmit_enter_count++; return NULL; } DEFINE_EXIT_FUNCTION(Transmit) { + (void)sm; transmit_exit_count++; return NULL; } DEFINE_EVENT_HANDLER_FUNCTION(Transmit) { - transmit_handle_count; + (void)event; + transmit_handle_count++; return NULL; } diff --git a/tests/service/task_worker/unittest_ez_task_worker.c b/tests/service/task_worker/unittest_ez_task_worker.c index c2f00df2..36b0ebee 100644 --- a/tests/service/task_worker/unittest_ez_task_worker.c +++ b/tests/service/task_worker/unittest_ez_task_worker.c @@ -143,7 +143,6 @@ static bool worker1_sum_external(int a, int b) { struct Worker1SumContext contxt; - bool ret = false; contxt.a = a; contxt.b = b; diff --git a/tests/utilities/linked_list/unittest_ez_linked_list.c b/tests/utilities/linked_list/unittest_ez_linked_list.c index 807c557c..db0692e1 100644 --- a/tests/utilities/linked_list/unittest_ez_linked_list.c +++ b/tests/utilities/linked_list/unittest_ez_linked_list.c @@ -292,8 +292,6 @@ TEST(ez_linked_list, LinkedList_UnlinkCurrentHead) TEST(ez_linked_list, ezLinkedList_IsNodeInList) { - uint32_t count = 0; - struct Node node1 = EZ_LINKEDLIST_INIT_NODE(node1); struct Node node2 = EZ_LINKEDLIST_INIT_NODE(node2); struct Node node3 = EZ_LINKEDLIST_INIT_NODE(node3); diff --git a/tests/utilities/queue/unittest_ez_queue.c b/tests/utilities/queue/unittest_ez_queue.c index bf147a59..075eb48f 100644 --- a/tests/utilities/queue/unittest_ez_queue.c +++ b/tests/utilities/queue/unittest_ez_queue.c @@ -120,7 +120,6 @@ TEST(ez_queue, CreateQueueSuccess) TEST(ez_queue, PopEmptyQueue) { ezSTATUS status = ezSUCCESS; - uint32_t queue_size = 0U; uint8_t *test_data = NULL; uint32_t test_data_size = 0U;