AVSystem/Anjay-esp32-client

mbedtls redefined warnings

AxelLin opened this issue · 2 comments

When I build with esp-idf CONFIG_MBEDTLS_ROM_MD5=y, I got below redefined warnings:

[944/1039] Building C object esp-idf/main/CMakeFiles/anjay.dir/anjay/deps/avs_commons/src/stream/md5/avs_stream_mbedtls.c.obj
/home/axel/esp/lwm2m/Anjay-esp32-client/main/anjay/deps/avs_commons/src/stream/md5/avs_stream_mbedtls.c:41: warning: "mbedtls_md5_update" redefined
 #        define mbedtls_md5_update mbedtls_md5_update_ret

In file included from /home/axel/esp/esp-idf/components/mbedtls/mbedtls/include/mbedtls/md5.h:94,
                 from /home/axel/esp/lwm2m/Anjay-esp32-client/main/anjay/deps/avs_commons/src/stream/md5/avs_stream_mbedtls.c:23:
/home/axel/esp/esp-idf/components/mbedtls/port/include/md5_alt.h:34: note: this is the location of the previous definition
 #define mbedtls_md5_update                      esp_md5_update

/home/axel/esp/lwm2m/Anjay-esp32-client/main/anjay/deps/avs_commons/src/stream/md5/avs_stream_mbedtls.c:42: warning: "mbedtls_md5_finish" redefined
 #        define mbedtls_md5_finish mbedtls_md5_finish_ret

In file included from /home/axel/esp/esp-idf/components/mbedtls/mbedtls/include/mbedtls/md5.h:94,
                 from /home/axel/esp/lwm2m/Anjay-esp32-client/main/anjay/deps/avs_commons/src/stream/md5/avs_stream_mbedtls.c:23:
/home/axel/esp/esp-idf/components/mbedtls/port/include/md5_alt.h:35: note: this is the location of the previous definition
 #define mbedtls_md5_finish                      esp_md5_finish


Note, CONFIG_MBEDTLS_ROM_MD5 is default y.

This stems from some API changes over the history of Mbed TLS:

  • Before Mbed TLS 2.7, there were only functions such as mbedtls_md5_starts(), which returned void
  • In Mbed TLS 2.7, these functions got deprecated, with new APIs called e.g. mbedtls_md5_starts_ret() added, able to return an error code as int
  • In Mbed TLS 3.0, the old deprecated APIs got removed, and the *_ret() APIs have been renamed to the names identical to the old pre-2.7 function names

avs_commons uses the Mbed TLS 3.0 APIs, and includes these #defines to bridge the API differences between versions and stay compatible with Mbed TLS 2.x, including the pre-2.7 versions.

These macros seem to conflict with some macros in ESP-IDF, but we have checked the consequences of that and verified that this is harmless.

The warnings will almost certainly disappear once ESP-IDF is updated to use Mbed TLS 3.x. Due to that, the harmlessness of the warning and the fact that it comes from compatibility code that affects platforms other than ESP-IDF as well, we decided to just ignore the issue and let the warning be reported.

@kFYatek
Thanks for the quick response and clarify it's harmless.