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

ES PERF array size calculation assumes "uint32" array base type #2030

Closed
jphickey opened this issue Jan 18, 2022 · 0 comments · Fixed by #2031 or #2019
Closed

ES PERF array size calculation assumes "uint32" array base type #2030

jphickey opened this issue Jan 18, 2022 · 0 comments · Fixed by #2031 or #2019
Assignees
Milestone

Comments

@jphickey
Copy link
Contributor

jphickey commented Jan 18, 2022

Describe the bug
The ES perf code uses macros to determine the array length based on the overall array size (via sizeof()). Problem is, these calculations hard-code a uint32 type as the divisor (element size) which may not always be true.

To Reproduce
Change the definition of the masks in TLM to be e.g. uint8-based instead of uint32-based. Array lengths are now calculated incorrectly, because it divides by sizeof(uint32) which would now be wrong.

Expected behavior
Should use [0] to get the actual type of the element, this makes the calculation future-proof, as it does not assume/repeat the array element type (adheres to DRY principle)

Code snips

#define CFE_ES_PERF_TRIGGERMASK_INT_SIZE \
(sizeof(CFE_ES_Global.ResetDataPtr->Perf.MetaData.TriggerMask) / sizeof(uint32))
#define CFE_ES_PERF_TRIGGERMASK_EXT_SIZE \
(sizeof(CFE_ES_Global.TaskData.HkPacket.Payload.PerfTriggerMask) / sizeof(uint32))
#define CFE_ES_PERF_FILTERMASK_INT_SIZE (sizeof(CFE_ES_Global.ResetDataPtr->Perf.MetaData.FilterMask) / sizeof(uint32))
#define CFE_ES_PERF_FILTERMASK_EXT_SIZE \
(sizeof(CFE_ES_Global.TaskData.HkPacket.Payload.PerfFilterMask) / sizeof(uint32))

System observed on:
Ubuntu 21.10

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this Jan 18, 2022
jphickey added a commit to jphickey/cFE that referenced this issue Jan 18, 2022
Cleans up the array length calculation for perf structs to not assume
a specific base element type (uint32).  This also makes the definitions
much more readable.
@astrogeco astrogeco added this to the Draco milestone Jan 19, 2022
astrogeco added a commit that referenced this issue Jan 19, 2022
Fix #2030, array length calculation for perf structs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants