Skip to content

Fix warnings emitted when compiling for mbedTLS and ESP_PLATFORM=1 #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

blake-spangenberg
Copy link

Fix warnings emitted when compiling c-core for our ESP-IDF v5.4 project

Warnings

  • pubnub_sync_subloop_define: GCC maintainers discourage the use of incomplete and unnamed struct initializers through the warning -Wmissing-field-initializers. As the use of a function in a struct initializer is not C89 compliant, I've fixed this by skipping the initialization of the struct and instead assigning it's values on subsequent lines.
  • pbpal_resolv_and_connect: There was an implicit cast in the arguments of connect and explicit cast was impossible due to the #define in pubnub_internal.h overshadowing the symbol. I've fixed this by removing the #define and being explicit in the case of ESP_PLATFORM == 1.
  • pubnub_assert_handler_abort: The pubnub_assert conventions heavily imply that abort functions should never return, but the compiler cannot assume pubnub_assert_handler_abort is __noreturn__ due to the volatile loop condition. I've removed this feature under the assumption that the debugging use case is niche.
  • pbntf_setup: The forward declaration did not match the actual function.

Other Feedback

  • CONTRIBUTING.md instructs to Pull Request into the develop branch, but that branch appears abandoned

  • I noticed for(;;) continue; is used in a few places in your code with the intention of aborting program execution. This is inadvisable as it is the compiler's discretion as to whether it omits a loop whose body has no observable effect as explained by Section 5.1.2.3 Program execution of the C99 specification:

In the abstract machine, all expressions are evaluated as specified by the semantics. An
actual implementation need not evaluate part of an expression if it can deduce that its
value is not used and that no needed side effects are produced (including any caused by
calling a function or accessing a volatile object).

This is not a problem on Xtensa GCC, but it may impact portability to other embedded architectures.

parfeon added a commit that referenced this pull request Jun 26, 2025
Fix the code for which compiler emitted warnings during the build for `mbedTLS` and `ESP_PLATFORM=1`

Closes #213
@parfeon parfeon closed this in 3792764 Jun 26, 2025
@pubnub-release-bot
Copy link
Contributor

@blake-spangenberg this issue is addressed in v5.1.1

@github-actions github-actions bot added the status: done This issue is considered resolved. label Jun 26, 2025
@blake-spangenberg blake-spangenberg deleted the fix-esp-idf-compilation branch June 29, 2025 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: done This issue is considered resolved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants