Skip to content
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

Merged
merged 2 commits into from
May 8, 2020

Conversation

jphickey
Copy link
Contributor

@jphickey jphickey commented May 6, 2020

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 of sizeof(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 of sizeof(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.

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.
@jphickey
Copy link
Contributor Author

jphickey commented May 6, 2020

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.

@skliper skliper added the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label May 6, 2020
@jphickey
Copy link
Contributor Author

jphickey commented May 6, 2020

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.

@jphickey jphickey linked an issue May 6, 2020 that may be closed by this pull request
@jphickey
Copy link
Contributor Author

jphickey commented May 6, 2020

Correction - it was #621 for the Shell packet warning, although as the FSW compiles cleanly it seems like #313 should be closed too anyway - likely covered as part of this or previous fixes.

@jphickey jphickey linked an issue May 6, 2020 that may be closed by this pull request
@jphickey
Copy link
Contributor Author

jphickey commented May 6, 2020

Submitted #679 for the issues in unit test code.

@skliper skliper removed the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label May 6, 2020
@astrogeco
Copy link
Contributor

CCB 20200506 - APPROVED

@skliper skliper added this to the 6.8.0 milestone May 7, 2020
@astrogeco astrogeco added CCB:Approved Indicates code review and approval by community CCB IC-20200429 labels May 8, 2020
@astrogeco astrogeco merged commit 8e8c465 into nasa:master May 8, 2020
@astrogeco
Copy link
Contributor

astrogeco commented May 8, 2020

@jphickey fyi made a mistake and merged to master directly. I cherry-picked merged into IC to make sure we have it there as well...

astrogeco added a commit that referenced this pull request May 8, 2020
Fix #666, alignment of CMD/TLM message definitions
@jphickey jphickey deleted the fix-666-sb-message-alignment branch May 21, 2020 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB
Projects
None yet
3 participants