Fix PXI I2C size decode - #976
Open
rosaage wants to merge 3 commits into
Open
Conversation
Wolfvak
reviewed
Aug 3, 2026
Comment on lines
+12
to
+15
| if (size >= SHMEM_BUFFER_SIZE) | ||
| return false; | ||
| if (size > 0x7FFF) | ||
| return false; |
Collaborator
There was a problem hiding this comment.
I'd rather see something like _Static_assert(SHMEM_BUFFER_SIZE < BIT(15)); rather than the two runtime checks here, but other than that it looks perfect
the "proper" way to fix it would be to define some types in shmem.h that describe the bitfield layout but that might be a bit too many changes, I'd rather have this as it's only used once or twice
Contributor
Author
There was a problem hiding this comment.
Wouldn't this potentially not work correctly?
if SHMEM_BUFFER_SIZE is 2048 (current value) and you try to read/write 4096 bytes, then nothing will stop that with a static assert of SHMEM_BUFFER_SIZE < BIT(31)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During some testing I discovered changing SHMEM_BUFFER_SIZE from
2048to20480broke I2C transfers.This was due to size not being calculated correctly.
Test code:
This was tested using onlinegdb.com:
Output of the test code with
sizeset to22:Old size: 12310, New size: 22The second commit adds a 15-bit size check to the arm9 side, rejecting commands early if size is too big.