-
Notifications
You must be signed in to change notification settings - Fork 8.2k
modem: cmux: Define encoding and decoding functions for commands #98009
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
base: main
Are you sure you want to change the base?
Conversation
5db7be3 to
67728fa
Compare
|
Fixed the compilation issues. Looks like we need to have static buffer instead of flexible array member, because we end up decoding the whole command and its included data. |
67728fa to
4012878
Compare
4012878 to
23f05e0
Compare
|
@bjarki-andreasen amended the PR to contain asserts and validation functions for commands static bool modem_cmux_command_type_is_valid(const struct modem_cmux_command_type type);
static bool modem_cmux_command_length_is_valid(const struct modem_cmux_command_length length);
static bool modem_cmux_command_is_valid(const struct modem_cmux_command *command);So type and length field and their EA bits are checked as well as length of all known commands. |
Instead of relying non-standard compiler behavior, define encode and decode functions for all CMUX command structures. Final command is encoded into a shared buffer, because it is always copied directly to TX ringbuffer. Added also functions to validate commands. Signed-off-by: Seppo Takalo <[email protected]>
23f05e0 to
1b76834
Compare
|
|
Ping @rerickson1 can you review please? I would like to rebase my #97362 on top of this, once merged. |
|
Just marking DNM because this does not seem to be a bugfix |
I would like to disagree with your conclusion. As a reference C11 standard: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf The important part are the two last sentences where this behavior is I'm a bit deadblocked here. My previous PR was blocked by a maintainer of that area when I was submitting a code that used bitfields to unpack a binary protocol. How should I deal with my follow up PR:s? Can I use a code that assumes bitfield to be packed on low-endian order, or not? |
This is a very good point, it is fixing issues with code in the tree. Please file an issue and tag this PR in the issue so we can follow the process to get this in during feature freeze. |
@SeppoTakalo - thanks for clarifying. It was not obvious to me based on the PR description (when I looked at it last time) |
|
I was just about to set the 4.4 milestone, when I noticed the latest comments. Please set the 4.3 milestone to indicate that you consider this for the upcoming release. |
If there is a feature freeze now, then I think this is fine for waiting, as I don't get the #97362 in either. This whole PR is about changing something that works as of now, on the compilers that we use today. |
|
Ok, I've added the 4.4 milestone now. That also helps remove some "noise" from https://merge-list.zephyrproject.io since this PR will not show up there until after the final 4.3 release. |



Instead of relying non-standard compiler behavior, define encode and decode functions for all CMUX command structures.
Drop:
And replace with:
as previous
_wrap_functions were relying on:to be placed correctly. But as discussed on PR #97569 here this is non-standard behavior.
Works on GCC on Arm and seem to be working on GCC on X86_64 native_sim, but we should not rely on that.
Fixes #98420