Skip to content

[Fix] compiler errors and warnings#72

Merged
QuangHaiNguyen merged 1 commit into
mainfrom
fix/compiler-warning
Apr 11, 2026
Merged

[Fix] compiler errors and warnings#72
QuangHaiNguyen merged 1 commit into
mainfrom
fix/compiler-warning

Conversation

@QuangHaiNguyen
Copy link
Copy Markdown
Collaborator

  • Activate several common build flag (check CMake file in src)
  • Fix all compiler errors/warnings

@QuangHaiNguyen QuangHaiNguyen requested a review from Copilot April 11, 2026 00:30
@QuangHaiNguyen QuangHaiNguyen self-assigned this Apr 11, 2026
@QuangHaiNguyen QuangHaiNguyen added bug Something isn't working enhancement New feature or request labels Apr 11, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make the framework build cleanly under stricter compiler settings by enabling common warning/security flags in CMake and addressing a broad set of compiler warnings/errors across core modules and unit tests.

Changes:

  • Enable stricter GCC/Clang compile flags (including -Werror) and adjust per-file options where needed.
  • Fix numerous warnings via unused-parameter handling, type casts, pointer arithmetic fixes, and API type alignment.
  • Update versioning metadata (project/version header) and remove an unused assert source unit.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
tests/utilities/queue/unittest_ez_queue.c Removes unused local variable in queue tests.
tests/utilities/linked_list/unittest_ez_linked_list.c Removes unused local variable in linked-list tests.
tests/service/task_worker/unittest_ez_task_worker.c Removes unused local variable in task worker tests.
tests/service/state_machine/unittest_ez_state_machine.c Suppresses unused-parameter warnings; fixes counter increment in handler.
tests/service/rpc/unittest_ez_rpc.cpp Suppresses unused-parameter warnings in test callbacks.
tests/service/event_bus/unittest_ez_event_bus.c Fixes a syntax issue (;;) in a test struct.
tests/service/driver/uart/unittest_ez_uart.c Suppresses unused-parameter warnings in mock UART driver.
tests/service/datamodel/unittest_ez_datamodel.cpp Updates data point initializer (adds dirty flag) and fixes shadowing.
tests/service/cli/unittest_ez_cli.c Suppresses unused-parameter warnings; adds cast for sprintf argument type.
src/utilities/queue/ez_queue.c Adjusts logging formats, allocator argument types, and hexdump size casts.
src/utilities/hexdump/ez_hexdump.c Updates hexdump API to use a wider size type; minor cleanup/typo fix.
src/utilities/CMakeLists.txt Removes assert/ez_assert.c from utilities build sources.
src/utilities/assert/ez_assert.c Deletes a no-op implementation file.
src/service/task_worker/ez_task_worker.c Fixes void* pointer arithmetic; suppresses unused args in no-RTOS paths.
src/service/state_machine/ez_state_machine.c Casts ring buffer size to match API expectations.
src/service/rpc/ez_rpc.c Narrows some stored types, fixes header serialization, and suppresses unused results.
src/service/ipc/ez_ipc.c Minor comment-block formatting fix.
src/service/event_bus/ez_event_bus.c Removes an unused local variable; minor size cast.
src/service/data_model/ez_data_model.c Removes ineffective const return; adjusts assert formatting.
src/service/cli/ez_cli.c Fixes an assignment bug, adjusts pointer handling/casts, and narrows send sizes.
src/middlewares/osal/ez_osal_threadx.c Adds casts and unused-arg suppression for stricter warnings.
src/middlewares/osal/ez_osal_freertos.c Fixes return type conversions and suppresses unused variable warnings.
src/middlewares/osal/CMakeLists.txt Adds per-file compile option to avoid cast-function-type being treated as error.
src/hal/uart/ez_uart.c Suppresses unused-parameter warning in non-debug builds.
src/hal/gpio/ez_gpio.c Removes unused local variable.
src/CMakeLists.txt Adds strict GCC/Clang warning/security flags (incl. -Werror, -Wconversion).
samples/linux/main.c Fixes main signature and return value for hosted environments.
inc/utilities/logging/ez_logging.h Renames color macros to EZ_* to reduce collisions; updates logging macros accordingly.
inc/utilities/hexdump/ez_hexdump.h Updates hexdump API declaration to use uint32_t size.
inc/service/rpc/ez_rpc.h Aligns response UUID type; removes unused local variable in inline helper.
inc/service/data_model/ez_data_model.h Removes ineffective const from uint32_t return type.
inc/service/cli/ez_cli.h Fixes callback typedef return qualifier (const char -> char).
inc/middlewares/osal/ez_osal.h Ensures handles are initialized in OSAL handle-definition macros.
inc/ez_version.h Updates SDK patch version string and numeric macros.
CMakeLists.txt Sets C++ standard and bumps project version; removes version-header generation.
cmake/ez_version.h.in Deletes the template previously used to generate inc/ez_version.h.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utilities/queue/ez_queue.c
Comment thread src/utilities/queue/ez_queue.c
Comment thread src/utilities/queue/ez_queue.c
Comment thread src/utilities/queue/ez_queue.c
Comment thread src/utilities/queue/ez_queue.c
Comment thread src/service/data_model/ez_data_model.c
Comment thread src/service/state_machine/ez_state_machine.c
Comment thread src/service/rpc/ez_rpc.c
Comment thread inc/utilities/logging/ez_logging.h
Comment thread CMakeLists.txt
@QuangHaiNguyen QuangHaiNguyen force-pushed the fix/compiler-warning branch 4 times, most recently from 5c9abf5 to 11e65aa Compare April 11, 2026 17:28
@QuangHaiNguyen QuangHaiNguyen requested a review from Copilot April 11, 2026 17:29
- Activate several common build flag (check CMake file in src)
- Fix all compiler errors/warnings
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 39 out of 40 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

src/service/event_bus/ez_event_bus.c:287

  • event_data_size is size_t but is cast to uint32_t when reserving queue space. Combined with ezQueue_ReserveElement allocating via a uint16_t allocator, large payloads can truncate and then memcpy() will overflow the reserved buffer. Add explicit bounds checks for event_data_size (<= UINT16_MAX if using ezStaticAlloc) and return an error when exceeded, instead of truncating.
    
    q_element_event_code = ezQueue_ReserveElement(&event_bus->event_queue, &code, sizeof(uint32_t));
    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)
    {
        EZWARNING("Cannot reserve event queue element");
        ezQueue_ReleaseReservedElement(&event_bus->event_queue, q_element_event_code);
        ezQueue_ReleaseReservedElement(&event_bus->event_queue, q_element_data);
        return false;
    }

    *(uint32_t*)code = event_code;
    memcpy(data, event_data, event_data_size);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utilities/queue/ez_queue.c
Comment thread src/utilities/queue/ez_queue.c
Comment thread src/utilities/queue/ez_queue.c
Comment thread src/service/data_model/ez_data_model.c
Comment thread .github/workflows/linux_unit_test.yaml
@QuangHaiNguyen QuangHaiNguyen merged commit 5123d7d into main Apr 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants