Fix C Bitfield Macros [DEVINFRA-655] #1110
Merged
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.
Description
This PR fixes a bug in the
SET
macros for bitfields.The current
SET
macros will fail if the client attempts to set a non-zero bitfield value to a new value. I've added a new test totest_imu_bitfields
inc/test/check_bitfield_macros.c
that demonstrates the bug:The change proposed clears the old values of the bitfields before setting the new value so that the expected result is correct.
@swift-nav/devinfra
API compatibility
The change was first proposed here (authored by @reimerix)
The contention was that the current behavior was correct for "flag" style bitfields, and the change might break clients relying on that behavior. The suggestion was to add a new macro with the desired behavior.
API compatibility plan
After further discussion and a review of our existing messages, we've concluded that the "flag" behavior was not supported to begin with.
Here is an example "flags" bitfield definition in our spec:
Each "flag" is declared explicitly and corresponding
GET
,SET
,MASK
, andSHIFT
macros are generated for each. The client is only able to SET a single bit at a time.So for example clients cannot do the following:
This has been added to the test suite;
test_packed_obs_bitfields
to demonstrate this usage of the API is not supported.The test passes before and after changing the SET implementation.
JIRA Reference
https://swift-nav.atlassian.net/browse/DEVINFRA-655