Skip to content

Introduce new CompostCtx struct that is passed into all the handlers#10

Open
blazra wants to merge 2 commits into
STMicroelectronics:mainfrom
blazra:context
Open

Introduce new CompostCtx struct that is passed into all the handlers#10
blazra wants to merge 2 commits into
STMicroelectronics:mainfrom
blazra:context

Conversation

@blazra
Copy link
Copy Markdown

@blazra blazra commented Apr 25, 2026

Allocator is now passed as part of the ctx. ctx also contains the rx and tx messages and user_ctx - a void pointer passed by the user to compost_msg_process()

Documentation needs to be changed.

PowerPC tests to be done.

Allocator is now passed as part of the `ctx`. `ctx` also contains the rx
and tx messages and `user_ctx` - a void pointer passed by the user to
`compost_msg_process()`
@blazraST blazraST requested a review from moucha19-st April 28, 2026 10:21
@moucha19-st
Copy link
Copy Markdown
Collaborator

The idea and implementation is solid, this change will cover a lot of different use cases in the future.

One small thing though, the test binary compiles with warnings due to unused ctx argument:

protocol_impl.c: In function ‘trigger_notification_handler’:
protocol_impl.c:68:54: warning: unused parameter ‘ctx’ [-Wunused-parameter]
   68 | void trigger_notification_handler(struct CompostCtx *ctx, uint16_t msg_id)
      |                                   ~~~~~~~~~~~~~~~~~~~^~~

I think this is the only drawback, that handler will always have this parameter but user won't necessarily need it every time. But I think it's fine, compared to some more complicated solutions, like having it optionally for only some RPC's.
However, you should still get rid of the warnings in the test handlers :)

@blazraST
Copy link
Copy Markdown
Collaborator

Yeah, the unused warning is annoying. I don't think there is a way how to silence it in C11. User will have to do the cast to void trick to silence the unused warning. I will do it in the test.

@blazraST
Copy link
Copy Markdown
Collaborator

blazraST commented May 4, 2026

PowerPC tests are passing. No more warnings. Ready to merge.

@blazraST blazraST linked an issue May 4, 2026 that may be closed by this pull request
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.

Pass context to every handler

3 participants