Skip to content

sys/event: add assertion that event has a handler#20847

Merged
Teufelchen1 merged 5 commits intoRIOT-OS:masterfrom
benpicco:event_assert
Oct 25, 2024
Merged

sys/event: add assertion that event has a handler#20847
Teufelchen1 merged 5 commits intoRIOT-OS:masterfrom
benpicco:event_assert

Conversation

@benpicco
Copy link
Copy Markdown
Contributor

Contribution description

When an uninitialized event is added, we will dereference a NULL pointer.
It can then be a bit tricky to find out which event caused this - so add an assertion when queuing the event that a callback is set.

Testing procedure

Issues/PRs references

@benpicco benpicco added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Aug 29, 2024
@github-actions github-actions bot added Area: network Area: Networking Area: CoAP Area: Constrained Application Protocol implementations Area: sys Area: System Area: examples Area: Example Applications labels Aug 29, 2024
@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 Aug 29, 2024
@riot-ci
Copy link
Copy Markdown

riot-ci commented Aug 29, 2024

Murdock results

✔️ PASSED

16c447a gcoap: make use of event_callback_post()

Success Failures Total Runtime
10193 0 10193 18m:19s

Artifacts

Copy link
Copy Markdown
Contributor

@Teufelchen1 Teufelchen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, would you mind reminding me if I have not come around for a proper review in a couple weeks?

Copy link
Copy Markdown
Contributor

@Teufelchen1 Teufelchen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Any specific reason you omitted an assert(cb) in callback.c event_callback_init(..)?

@benpicco
Copy link
Copy Markdown
Contributor Author

A callback struct with a NULL handler does no harm in itself.
Only when you try to add it to an event queue, things will blow up.

@Teufelchen1 Teufelchen1 added this pull request to the merge queue Oct 25, 2024
Merged via the queue into RIOT-OS:master with commit b376bec Oct 25, 2024
@benpicco benpicco deleted the event_assert branch October 25, 2024 11:42
@benpicco benpicco added this to the Release 2024.10 milestone Nov 27, 2024
@MrKevinWeiss MrKevinWeiss added this to the Release 2025.01 milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: CoAP Area: Constrained Application Protocol implementations Area: examples Area: Example Applications Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants