-
Notifications
You must be signed in to change notification settings - Fork 206
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
Fix #666, alignment of CMD/TLM message definitions #678
Conversation
The "CFE_SB_CmdHdr_t" and "CFE_SB_TlmHdr_t" types were not defined such that they would have compatible alignment with (and thereby allow safe casting to/from) a CFE_SB_Msg_t type. This changes the definition to be a union so that the types are aligned correctly.
Update the CFE_ES_ShellTlm_t, CFE_TIME_ToneSignalCmd_t, and CFE_TIME_FakeToneCmd_t to use the CFE_SB_TlmHdr_t/CFE_SB_CmdHdr_t types to define the buffer, rather than a uint8 array. This should not change the size, as it was already defined using sizeof() this structure, but it will make it aligned correctly which resolves the compiler warning. Note that all CMD/TLM should really be defined this way, but this only selectively changes the places that were actually generating a compiler warning about this. There is a risk that padding will be added, but this change should not change the padding or size of messages in 32-bit builds.
Also note this PR only fixes warnings within the FSW code. I'm still seeing several alignment cast warnings in the unit test code on my 32-bit test platform. Will submit a separate issue about that. |
Note that this also fixes #313 as it changes the CFE_ES_ShellTlm_t definition to be aligned. Even though this is on its way to being deprecated/optional this was generating a warning and causing the build to fail. |
Submitted #679 for the issues in unit test code. |
CCB 20200506 - APPROVED |
@jphickey fyi made a mistake and merged to master directly. I |
Fix #666, alignment of CMD/TLM message definitions
Describe the contribution
Define the SB message headers such that they are aligned appropriately for casting to/from a
CFE_SB_Msg_t
type. Note this should not affect the size of these structures on a 32-bit machine with the default configuration, as they are already multiples ofsizeof(uint32)
....Then change only the CMD/TLM definitions which were generating warnings on the 32-bit build to use this correct definition, rather than a
uint8[]
array to reserve space for the header. Again in these cases this should not change the size or padding because it already was multiples ofsizeof(uint32)
. This just makes it so the compiler will appropriately align the overall buffer.Fix #666
Testing performed
Build for 64 + 32 bit platforms with strict alignment settings and confirm that the warnings are gone. Confirm all tests pass.
Expected behavior changes
No impact to behavior.
System(s) tested on
Ubuntu 20.04
MIPS yocto/poky embedded Linux (32-bit big endian processor with strict alignment requirements)
RTEMS on QEMU (i686-rtems4.11)
Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.