From f28181d920044e73ac9f91a887c6bce983200c04 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Wed, 3 May 2023 08:47:07 +1000 Subject: [PATCH] Fix #82, Convert integers holding boolean truth values to `bool` --- fsw/inc/cs_msg.h | 4 ++-- fsw/inc/cs_tbldefs.h | 10 ++++++---- fsw/src/cs_compute.c | 5 ++--- unit-test/cs_app_tests.c | 8 ++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/fsw/inc/cs_msg.h b/fsw/inc/cs_msg.h index 45356e3..b73569a 100644 --- a/fsw/inc/cs_msg.h +++ b/fsw/inc/cs_msg.h @@ -48,8 +48,8 @@ typedef struct uint8 TablesCSState; /**< \brief CS Tables table checksum state */ uint8 OSCSState; /**< \brief OS code segment checksum state */ uint8 CfeCoreCSState; /**< \brief cFE Core code segment checksum stat e*/ - uint8 RecomputeInProgress; /**< \brief CS "Recompute In Progress" flag */ - uint8 OneShotInProgress; /**< \brief CS "OneShot In Progress" flag */ + bool RecomputeInProgress; /**< \brief CS "Recompute In Progress" flag */ + bool OneShotInProgress; /**< \brief CS "OneShot In Progress" flag */ uint8 Filler8; /**< \brief 8 bit padding */ uint16 EepromCSErrCounter; /**< \brief EEPROM miscompare counter */ uint16 MemoryCSErrCounter; /**< \brief Memory miscompare counter */ diff --git a/fsw/inc/cs_tbldefs.h b/fsw/inc/cs_tbldefs.h index 51c2640..0e34463 100644 --- a/fsw/inc/cs_tbldefs.h +++ b/fsw/inc/cs_tbldefs.h @@ -81,7 +81,8 @@ typedef struct { cpuaddr StartAddress; /**< \brief The Start address to Checksum */ uint16 State; /**< \brief Uses the CS_STATE_... defines from above */ - uint16 ComputedYet; /**< \brief Have we computed an Integrity value yet */ + bool ComputedYet; /**< \brief Have we computed an Integrity value yet */ + bool Filler8; /** <\brief Padding */ uint32 NumBytesToChecksum; /**< \brief The number of Bytes to Checksum */ uint32 ComparisonValue; /**< \brief The Memory Integrity Value */ uint32 ByteOffset; /**< \brief Where a previous unfinished calc left off */ @@ -114,14 +115,14 @@ typedef struct { cpuaddr StartAddress; /**< \brief The Start address to Checksum */ uint16 State; /**< \brief Uses the CS_STATE_... defines from above */ - uint16 ComputedYet; /**< \brief Have we computed an Integrity value yet */ + bool ComputedYet; /**< \brief Have we computed an Integrity value yet */ uint32 NumBytesToChecksum; /**< \brief The number of Bytes to Checksum */ uint32 ComparisonValue; /**< \brief The Memory Integrity Value */ uint32 ByteOffset; /**< \brief Where a previous unfinished calc left off */ uint32 TempChecksumValue; /**< \brief The unfinished caluculation */ CFE_TBL_Handle_t TblHandle; /**< \brief handle recieved from CFE_TBL */ bool IsCSOwner; /**< \brief Is CS the original owner of this table */ - bool Filler8; /**< \brief Padding */ + uint16 Filler16; /**< \brief Padding */ char Name[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief name of the table */ } CS_Res_Tables_Table_Entry_t; @@ -132,7 +133,8 @@ typedef struct { cpuaddr StartAddress; /**< \brief The Start address to Checksum */ uint16 State; /**< \brief Uses the CS_STATE_... defines from above */ - uint16 ComputedYet; /**< \brief Have we computed an Integrity value yet */ + bool ComputedYet; /**< \brief Have we computed an Integrity value yet */ + bool Filler8; /** <\brief Padding */ uint32 NumBytesToChecksum; /**< \brief The number of Bytes to Checksum */ uint32 ComparisonValue; /**< \brief The Memory Integrity Value */ uint32 ByteOffset; /**< \brief Where a previous unfinished calc left off */ diff --git a/fsw/src/cs_compute.c b/fsw/src/cs_compute.c index 167e77c..fccbacb 100644 --- a/fsw/src/cs_compute.c +++ b/fsw/src/cs_compute.c @@ -315,7 +315,7 @@ CFE_Status_t CS_ComputeApp(CS_Res_App_Table_Entry_t *ResultsEntry, uint32 *Compu CFE_Status_t Result; CFE_Status_t ResultGetResourceID = CS_ERROR; CFE_Status_t ResultGetResourceInfo = CS_ERROR; - int32 ResultAddressValid = false; + bool ResultAddressValid = false; /* variables to get applications address */ CFE_ResourceId_t ResourceID = CFE_RESOURCEID_UNDEFINED; @@ -350,8 +350,7 @@ CFE_Status_t CS_ComputeApp(CS_Res_App_Table_Entry_t *ResultsEntry, uint32 *Compu { CFE_EVS_SendEvent(CS_COMPUTE_APP_PLATFORM_DBG_EID, CFE_EVS_EventType_DEBUG, "CS cannot get a valid address for %s, due to the platform", ResultsEntry->Name); - ResultAddressValid = false; - Result = CS_ERROR; + Result = CS_ERROR; } else { diff --git a/unit-test/cs_app_tests.c b/unit-test/cs_app_tests.c index 427e521..6bb03e2 100644 --- a/unit-test/cs_app_tests.c +++ b/unit-test/cs_app_tests.c @@ -2188,8 +2188,8 @@ void CS_HousekeepingCmd_Test_Nominal(void) CS_AppData.HkPacket.TablesCSState = 7; CS_AppData.HkPacket.OSCSState = 8; CS_AppData.HkPacket.CfeCoreCSState = 9; - CS_AppData.HkPacket.RecomputeInProgress = 10; - CS_AppData.HkPacket.OneShotInProgress = 11; + CS_AppData.HkPacket.RecomputeInProgress = true; + CS_AppData.HkPacket.OneShotInProgress = true; CS_AppData.HkPacket.EepromCSErrCounter = 12; CS_AppData.HkPacket.MemoryCSErrCounter = 13; CS_AppData.HkPacket.AppCSErrCounter = 14; @@ -2219,8 +2219,8 @@ void CS_HousekeepingCmd_Test_Nominal(void) UtAssert_True(CS_AppData.HkPacket.TablesCSState == 7, "CS_AppData.HkPacket.TablesCSState == 7"); UtAssert_True(CS_AppData.HkPacket.OSCSState == 8, "CS_AppData.HkPacket.OSCSState == 8"); UtAssert_True(CS_AppData.HkPacket.CfeCoreCSState == 9, "CS_AppData.HkPacket.CfeCoreCSState == 9"); - UtAssert_True(CS_AppData.HkPacket.RecomputeInProgress == 10, "CS_AppData.HkPacket.ChildTaskInUse == 10"); - UtAssert_True(CS_AppData.HkPacket.OneShotInProgress == 11, "CS_AppData.HkPacket.OneShotInProgress == 11"); + UtAssert_True(CS_AppData.HkPacket.RecomputeInProgress == true, "CS_AppData.HkPacket.ChildTaskInUse == true"); + UtAssert_True(CS_AppData.HkPacket.OneShotInProgress == true, "CS_AppData.HkPacket.OneShotInProgress == true"); UtAssert_True(CS_AppData.HkPacket.EepromCSErrCounter == 12, "CS_AppData.HkPacket.EepromCSErrCounter == 12"); UtAssert_True(CS_AppData.HkPacket.MemoryCSErrCounter == 13, "CS_AppData.HkPacket.MemoryCSErrCounter == 13"); UtAssert_True(CS_AppData.HkPacket.AppCSErrCounter == 14, "CS_AppData.HkPacket.AppCSErrCounter == 14");