From f5982166196fa362542eb8ee293c97ee4f09556b Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 18 Jan 2022 16:58:38 -0500 Subject: [PATCH] Fix #2030, array length calculation for perf structs 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. --- modules/es/fsw/src/cfe_es_task.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/es/fsw/src/cfe_es_task.c b/modules/es/fsw/src/cfe_es_task.c index 4703763f1..4298a76c7 100644 --- a/modules/es/fsw/src/cfe_es_task.c +++ b/modules/es/fsw/src/cfe_es_task.c @@ -48,13 +48,16 @@ /* ** Defines */ +#define CFE_ES_PERF_MASK_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) + #define CFE_ES_PERF_TRIGGERMASK_INT_SIZE \ - (sizeof(CFE_ES_Global.ResetDataPtr->Perf.MetaData.TriggerMask) / sizeof(uint32)) + CFE_ES_PERF_MASK_ARRAY_SIZE(CFE_ES_Global.ResetDataPtr->Perf.MetaData.TriggerMask) #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)) + CFE_ES_PERF_MASK_ARRAY_SIZE(CFE_ES_Global.TaskData.HkPacket.Payload.PerfTriggerMask) +#define CFE_ES_PERF_FILTERMASK_INT_SIZE \ + CFE_ES_PERF_MASK_ARRAY_SIZE(CFE_ES_Global.ResetDataPtr->Perf.MetaData.FilterMask) #define CFE_ES_PERF_FILTERMASK_EXT_SIZE \ - (sizeof(CFE_ES_Global.TaskData.HkPacket.Payload.PerfFilterMask) / sizeof(uint32)) + CFE_ES_PERF_MASK_ARRAY_SIZE(CFE_ES_Global.TaskData.HkPacket.Payload.PerfFilterMask) /* ** This define should be put in the OS API headers -- Right now it matches what the OS API uses