eclipse-zenoh / zenoh-pico

Eclipse zenoh for pico devices
Other
122 stars 78 forks source link

Fix: system call error processing #776

Closed WilliamGFish closed 2 weeks ago

WilliamGFish commented 2 weeks ago

OK, found the issue, it relates to PR #586 ( Fix system calls return error processing)

Causes compilation errors:

C:/gnu_arm_embedded_13/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.bfd.exe: modules/zenoh-pico/lib..externalzenoh-pico__zephyr.a(system.c.obj): in function _z_task_init': C:/zephyr/external/zenoh-pico/src/system/zephyr/system.c:83:(.text._z_task_init+0x3c): undefined reference to _z_report_system_error'

They are calling a function within a Marco which causes a compilation problem:

void _z_report_system_error(int errcode);

#define _Z_CHECK_SYS_ERR(expr)             \
    do {                                   \
        int __res = expr;                  \
        if (__res != 0) {                  \
            _z_report_system_error(__res); \
            return _Z_ERR_SYSTEM_GENERIC;  \
        }                                  \
        return _Z_RES_OK;                  \
    } while (false)

Unfortunately, #define is a pre-processor directive used in C programs to define macros so the function has not been defined. Removing the function call and some logic amends it could be:

#define _Z_CHECK_SYS_ERR(expr)            \
    do {                                  \
        int __res = expr;                 \
        if (__res > 0) {                  \
            return _Z_ERR_SYSTEM_GENERIC; \
        }                                 \
        return __res;                     \
    } while (false)

Fixes Issue: #775 [Bug] zenoh-pico: zephyr: Compilation Errors

Billy..

github-actions[bot] commented 2 weeks ago

PR missing one of the required labels: {'internal', 'dependencies', 'documentation', 'enhancement', 'bug', 'breaking-change', 'new feature'}

sashacmc commented 2 weeks ago

The problem is that platform_common.c (where _z_report_system_error is defined) is not included in CMakeLists.txt for zephyr, thanks for pointing that out. Here is the fix, please check that it works for you: https://github.com/eclipse-zenoh/zenoh-pico/pull/778