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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant