Skip to content
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

pkg/openthread: fix code style, error handling, and synchronization #19638

Closed
wants to merge 2 commits into from

Conversation

maribu
Copy link
Member

@maribu maribu commented May 20, 2023

Contribution description

  • fix code style
  • add error handling to pkg/openthread/contrib/platform_functions_wrapper.c
  • let ot_call_command() wait for the command to actually complete
    • right now, ot_call_command() would return before the command is executed if called from a higher priority thread than OT is running in or when the OT thread blocks. The latter is pretty likely
    • but given that there was zero error handling anyway, this would likely go unnoticed. Now that there is error handling and the return value of ot_call_command() actually can be non-zero, it is important to wait for the command to complete before checking its error status

Testing procedure

  • no regressions on OT
  • error handling should now actually work

Issues/PRs references

Split out of #19634

maribu added 2 commits May 20, 2023 22:23
Various code style fix that shouldn't change the generated machine
code.

In addition, many internal functions provided symbols with no reason
to do so. Those internal functions and variables are now declared
as `static`.
Previously, there was zero error handling in the ot_command_t commands
provided in pkg/openthread/contrib/platform_functions_wrapper.c -
ignoring the return value even of functions that are marked with
`OT_MUST_USE_RESULT`.

In addition, `ot_call_command()` never synchronized with the thread
executing the command before return the value. Given that there was
no error handling anyways, this likely was never noticed. But now that
the commands actually report an error, it is of utmost importance to
actually wait for the command to complete before checking the
commands return value.
@maribu maribu added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: pkg Area: External package ports Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch labels May 20, 2023
@maribu maribu requested a review from jia200x as a code owner May 20, 2023 20:28
@github-actions github-actions bot added the Area: network Area: Networking label May 20, 2023
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 22, 2023
@benpicco benpicco changed the title kkg/openthread: fix code style, error handling, and sychronization pkg/openthread: fix code style, error handling, and sychronization May 22, 2023
@aabadie aabadie changed the title pkg/openthread: fix code style, error handling, and sychronization pkg/openthread: fix code style, error handling, and synchronization May 22, 2023
@riot-ci
Copy link

riot-ci commented May 22, 2023

Murdock results

✔️ PASSED

f88e65d pkg/openthread: fix error handling and synchronization

Success Failures Total Runtime
6946 0 6946 09m:54s

Artifacts

@jia200x
Copy link
Member

jia200x commented May 23, 2023

FYI, those "ot_command" functions were deprecated some years ago. I'm surprised to see they still exist 😮

Since then OpenThread runs on an event queue, which automatically allows to call pkg API functions without synchronization issues (since all OpenThread API calls use tasklets internally to process function calls). See e.g https://github.com/RIOT-OS/RIOT/blob/master/examples/openthread/main.c#L31

@maribu maribu closed this Jul 17, 2023
@maribu maribu deleted the pkg/openthread branch July 17, 2023 13:05
@maribu
Copy link
Member Author

maribu commented Jul 17, 2023

Not needed anymore with #19685 merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants