diff --git a/.github/workflows/codeql-build.yml b/.github/workflows/codeql-build.yml index 263da4f..1b2781a 100644 --- a/.github/workflows/codeql-build.yml +++ b/.github/workflows/codeql-build.yml @@ -4,7 +4,6 @@ on: push: pull_request: - jobs: codeql: name: Codeql Analysis diff --git a/fsw/inc/cs_tbldefs.h b/fsw/inc/cs_tbldefs.h index 51c2640..efb892c 100644 --- a/fsw/inc/cs_tbldefs.h +++ b/fsw/inc/cs_tbldefs.h @@ -339,7 +339,7 @@ void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionT * \param [in] SizeofDefinitionTableEntry The sizeof an entry in the * definition table * - * \param [in] SizeofResultsTableEntry The size of an enrty in the + * \param [in] SizeofResultsTableEntry The size of an entry in the * results table * * \param [in] CallBackFunction A pointer to a function used to @@ -367,7 +367,7 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl void *DefinitionTblPtr, void *ResultsTblPtr, const uint16 Table, const char *DefinitionTableName, const char *ResultsTableName, const uint16 NumEntries, const char *DefinitionTableFileName, const void *DefaultDefTableAddress, - const uint16 SizeofDefinitionTableEntry, const uint16 SizeofResultsTableEntry, + const size_t SizeofDefinitionTableEntry, const size_t SizeofResultsTableEntry, const CFE_TBL_CallbackFuncPtr_t CallBackFunction); /** diff --git a/fsw/src/cs_app.c b/fsw/src/cs_app.c index 6191140..4495525 100644 --- a/fsw/src/cs_app.c +++ b/fsw/src/cs_app.c @@ -58,7 +58,7 @@ CS_AppData_t CS_AppData; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_AppMain(void) { - CFE_Status_t Result = 0; + CFE_Status_t Result; CFE_SB_Buffer_t *BufPtr = NULL; /* Performance Log (start time counter) */ @@ -147,7 +147,7 @@ void CS_AppMain(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_AppInit(void) { - CFE_Status_t Result = CFE_SUCCESS; + CFE_Status_t Result; /* Register for event services */ Result = CFE_EVS_Register(NULL, 0, 0); @@ -264,8 +264,8 @@ CFE_Status_t CS_AppPipe(const CFE_SB_Buffer_t *BufPtr) void CS_ProcessCmd(const CFE_SB_Buffer_t *BufPtr) { - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; - uint16 CommandCode = 0; + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t CommandCode = 0; CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID); diff --git a/fsw/src/cs_app_cmds.c b/fsw/src/cs_app_cmds.c index 491fc0f..e4015bd 100644 --- a/fsw/src/cs_app_cmds.c +++ b/fsw/src/cs_app_cmds.c @@ -46,13 +46,19 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_DisableAppCmd(const CS_NoArgsCmd_t *CmdPtr) { + bool Status; + /* command verification variables */ size_t ExpectedLength = sizeof(CS_NoArgsCmd_t); /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { - if (CS_CheckRecomputeOneshot() == false) + Status = CS_CheckRecomputeOneshot(); + + if (!Status) { CS_AppData.HkPacket.AppCSState = CS_STATE_DISABLED; CS_ZeroAppTempValues(); @@ -74,13 +80,19 @@ void CS_DisableAppCmd(const CS_NoArgsCmd_t *CmdPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_EnableAppCmd(const CS_NoArgsCmd_t *CmdPtr) { + bool Status; + /* command verification variables */ size_t ExpectedLength = sizeof(CS_NoArgsCmd_t); /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { - if (CS_CheckRecomputeOneshot() == false) + Status = CS_CheckRecomputeOneshot(); + + if (!Status) { CS_AppData.HkPacket.AppCSState = CS_STATE_ENABLED; @@ -107,14 +119,19 @@ void CS_ReportBaselineAppCmd(const CS_AppNameCmd_t *CmdPtr) CS_Res_App_Table_Entry_t *ResultsEntry; uint32 Baseline; char Name[OS_MAX_API_NAME]; + bool Status; /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { strncpy(Name, CmdPtr->Name, sizeof(Name) - 1); Name[sizeof(Name) - 1] = '\0'; - if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) + Status = CS_GetAppResTblEntryByName(&ResultsEntry, Name); + + if (Status) { if (ResultsEntry->ComputedYet == true) { @@ -152,10 +169,13 @@ void CS_RecomputeBaselineAppCmd(const CS_AppNameCmd_t *CmdPtr) CFE_Status_t Status; CS_Res_App_Table_Entry_t *ResultsEntry; char Name[OS_MAX_API_NAME]; + bool Result; /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Result = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Result) { if (CS_AppData.HkPacket.RecomputeInProgress == false && CS_AppData.HkPacket.OneShotInProgress == false) { @@ -163,7 +183,9 @@ void CS_RecomputeBaselineAppCmd(const CS_AppNameCmd_t *CmdPtr) Name[sizeof(Name) - 1] = '\0'; /* make sure the entry is a valid number and is defined in the table */ - if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) + Result = CS_GetAppResTblEntryByName(&ResultsEntry, Name); + + if (Result) { /* There is no child task running right now, we can use it*/ CS_AppData.HkPacket.RecomputeInProgress = true; @@ -220,16 +242,23 @@ void CS_DisableNameAppCmd(const CS_AppNameCmd_t *CmdPtr) CS_Res_App_Table_Entry_t *ResultsEntry; CS_Def_App_Table_Entry_t *DefinitionEntry; char Name[OS_MAX_API_NAME]; + bool Status; /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { - if (CS_CheckRecomputeOneshot() == false) + Status = CS_CheckRecomputeOneshot(); + + if (!Status) { strncpy(Name, CmdPtr->Name, sizeof(Name) - 1); Name[sizeof(Name) - 1] = '\0'; - if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) + Status = CS_GetAppResTblEntryByName(&ResultsEntry, Name); + + if (Status) { ResultsEntry->State = CS_STATE_DISABLED; ResultsEntry->TempChecksumValue = 0; @@ -238,7 +267,9 @@ void CS_DisableNameAppCmd(const CS_AppNameCmd_t *CmdPtr) CFE_EVS_SendEvent(CS_DISABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of app %s is Disabled", Name); - if (CS_GetAppDefTblEntryByName(&DefinitionEntry, Name)) + Status = CS_GetAppDefTblEntryByName(&DefinitionEntry, Name); + + if (Status) { DefinitionEntry->State = CS_STATE_DISABLED; CS_ResetTablesTblResultEntry(CS_AppData.AppResTablesTblPtr); @@ -252,7 +283,6 @@ void CS_DisableNameAppCmd(const CS_AppNameCmd_t *CmdPtr) CS_AppData.HkPacket.CmdCounter++; } - else { CFE_EVS_SendEvent(CS_DISABLE_APP_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, @@ -276,23 +306,32 @@ void CS_EnableNameAppCmd(const CS_AppNameCmd_t *CmdPtr) CS_Res_App_Table_Entry_t *ResultsEntry; CS_Def_App_Table_Entry_t *DefinitionEntry; char Name[OS_MAX_API_NAME]; + bool Status; /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { - if (CS_CheckRecomputeOneshot() == false) + Status = CS_CheckRecomputeOneshot(); + + if (!Status) { strncpy(Name, CmdPtr->Name, sizeof(Name) - 1); Name[sizeof(Name) - 1] = '\0'; - if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) + Status = CS_GetAppResTblEntryByName(&ResultsEntry, Name); + + if (Status) { ResultsEntry->State = CS_STATE_ENABLED; CFE_EVS_SendEvent(CS_ENABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of app %s is Enabled", Name); - if (CS_GetAppDefTblEntryByName(&DefinitionEntry, Name)) + Status = CS_GetAppDefTblEntryByName(&DefinitionEntry, Name); + + if (Status) { DefinitionEntry->State = CS_STATE_ENABLED; CS_ResetTablesTblResultEntry(CS_AppData.AppResTablesTblPtr); diff --git a/fsw/src/cs_compute.c b/fsw/src/cs_compute.c index 167e77c..e836f18 100644 --- a/fsw/src/cs_compute.c +++ b/fsw/src/cs_compute.c @@ -125,9 +125,9 @@ CFE_Status_t CS_ComputeTables(CS_Res_Tables_Table_Entry_t *ResultsEntry, uint32 uint32 NewChecksumValue = 0; CFE_Status_t Status = CFE_SUCCESS; CFE_Status_t Result = CFE_SUCCESS; - CFE_Status_t ResultShare = 0; - CFE_Status_t ResultGetInfo = 0; - CFE_Status_t ResultGetAddress = 0; + CFE_Status_t ResultShare; + CFE_Status_t ResultGetInfo = 0; + CFE_Status_t ResultGetAddress = 0; /* variables to get the table address */ CFE_TBL_Handle_t LocalTblHandle = CFE_TBL_BAD_TABLE_HANDLE; @@ -313,7 +313,7 @@ CFE_Status_t CS_ComputeApp(CS_Res_App_Table_Entry_t *ResultsEntry, uint32 *Compu uint32 NewChecksumValue = 0; CFE_Status_t Status = CFE_SUCCESS; CFE_Status_t Result; - CFE_Status_t ResultGetResourceID = CS_ERROR; + CFE_Status_t ResultGetResourceID; CFE_Status_t ResultGetResourceInfo = CS_ERROR; int32 ResultAddressValid = false; @@ -781,11 +781,11 @@ void CS_RecomputeTablesChildTask(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_OneShotChildTask(void) { - uint32 NewChecksumValue = 0; - uint32 NumBytesRemainingCycles = 0; - uint32 NumBytesThisCycle = 0; - cpuaddr FirstAddrThisCycle = 0; - uint32 MaxBytesPerCycle = 0; + uint32 NewChecksumValue; + uint32 NumBytesRemainingCycles; + uint32 NumBytesThisCycle; + cpuaddr FirstAddrThisCycle; + uint32 MaxBytesPerCycle; NewChecksumValue = 0; NumBytesRemainingCycles = CS_AppData.HkPacket.LastOneShotSize; diff --git a/fsw/src/cs_compute.h b/fsw/src/cs_compute.h index 2e33273..6f89bd9 100644 --- a/fsw/src/cs_compute.h +++ b/fsw/src/cs_compute.h @@ -40,7 +40,6 @@ * function is used to compute checksums for EEPROM, Memory, the * OS code segment and the cFE core code segment * - * * \par Assumptions, External Events, and Notes: * None * diff --git a/fsw/src/cs_eeprom_cmds.c b/fsw/src/cs_eeprom_cmds.c index f1ac6cf..aecc815 100644 --- a/fsw/src/cs_eeprom_cmds.c +++ b/fsw/src/cs_eeprom_cmds.c @@ -110,9 +110,9 @@ void CS_ReportBaselineEntryIDEepromCmd(const CS_EntryCmd_t *CmdPtr) /* command verification variables */ size_t ExpectedLength = sizeof(CS_EntryCmd_t); - uint32 Baseline = 0; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint32 Baseline; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; CS_Res_EepromMemory_Table_Entry_t ResultsEntry; /* Verify command packet length */ @@ -169,9 +169,9 @@ void CS_RecomputeBaselineEepromCmd(const CS_EntryCmd_t *CmdPtr) size_t ExpectedLength = sizeof(CS_EntryCmd_t); CFE_ES_TaskId_t ChildTaskID = CFE_ES_TASKID_UNDEFINED; - CFE_Status_t Status = CS_ERROR; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + CFE_Status_t Status; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; /* Verify command packet length */ if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) @@ -252,8 +252,8 @@ void CS_EnableEntryIDEepromCmd(const CS_EntryCmd_t *CmdPtr) size_t ExpectedLength = sizeof(CS_EntryCmd_t); CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; /* Verify command packet length */ if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) @@ -318,8 +318,8 @@ void CS_DisableEntryIDEepromCmd(const CS_EntryCmd_t *CmdPtr) size_t ExpectedLength = sizeof(CS_EntryCmd_t); CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; /* Verify command packet length */ if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) @@ -387,8 +387,8 @@ void CS_GetEntryIDEepromCmd(const CS_GetEntryIDCmd_t *CmdPtr) size_t ExpectedLength = sizeof(CS_GetEntryIDCmd_t); CS_Res_EepromMemory_Table_Entry_t *StartOfResultsTable = NULL; - uint16 Loop = 0; - bool EntryFound = false; + uint16 Loop; + bool EntryFound = false; CS_Res_EepromMemory_Table_Entry_t ResultsEntry; /* Verify command packet length */ diff --git a/fsw/src/cs_init.c b/fsw/src/cs_init.c index 1fd31c5..cce204e 100644 --- a/fsw/src/cs_init.c +++ b/fsw/src/cs_init.c @@ -39,7 +39,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_SbInit(void) { - CFE_Status_t Result = CFE_SUCCESS; + CFE_Status_t Result; /* Initialize app configuration data */ strncpy(CS_AppData.PipeName, CS_CMD_PIPE_NAME, CS_CMD_PIPE_NAME_LEN); @@ -99,7 +99,7 @@ CFE_Status_t CS_SbInit(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_InitAllTables(void) { - CFE_Status_t ResultInit = CFE_SUCCESS; + CFE_Status_t ResultInit; ResultInit = CS_TableInit(&CS_AppData.DefEepromTableHandle, &CS_AppData.ResEepromTableHandle, (void *)&CS_AppData.DefEepromTblPtr, (void *)&CS_AppData.ResEepromTblPtr, CS_EEPROM_TABLE, @@ -174,7 +174,7 @@ CFE_Status_t CS_InitAllTables(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_InitSegments(void) { - int32 ResultSegment = OS_SUCCESS; + int32 ResultSegment; uint32 CFESize; cpuaddr CFEAddress; uint32 KernelSize; diff --git a/fsw/src/cs_memory_cmds.c b/fsw/src/cs_memory_cmds.c index 342e884..98c2c38 100644 --- a/fsw/src/cs_memory_cmds.c +++ b/fsw/src/cs_memory_cmds.c @@ -110,9 +110,9 @@ void CS_ReportBaselineEntryIDMemoryCmd(const CS_EntryCmd_t *CmdPtr) /* command verification variables */ size_t ExpectedLength = sizeof(CS_EntryCmd_t); CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint32 Baseline = 0; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint32 Baseline; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; /* Verify command packet length */ if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) @@ -167,9 +167,9 @@ void CS_RecomputeBaselineMemoryCmd(const CS_EntryCmd_t *CmdPtr) /* command verification variables */ size_t ExpectedLength = sizeof(CS_EntryCmd_t); CFE_ES_TaskId_t ChildTaskID = CFE_ES_TASKID_UNDEFINED; - CFE_Status_t Status = CS_ERROR; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + CFE_Status_t Status; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; /* Verify command packet length */ if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) @@ -249,8 +249,8 @@ void CS_EnableEntryIDMemoryCmd(const CS_EntryCmd_t *CmdPtr) /* command verification variables */ size_t ExpectedLength = sizeof(CS_EntryCmd_t); CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; /* Verify command packet length */ if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) @@ -314,8 +314,8 @@ void CS_DisableEntryIDMemoryCmd(const CS_EntryCmd_t *CmdPtr) /* command verification variables */ size_t ExpectedLength = sizeof(CS_EntryCmd_t); CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; /* Verify command packet length */ if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) @@ -383,8 +383,8 @@ void CS_GetEntryIDMemoryCmd(const CS_GetEntryIDCmd_t *CmdPtr) size_t ExpectedLength = sizeof(CS_GetEntryIDCmd_t); CS_Res_EepromMemory_Table_Entry_t *StartOfResultsTable = NULL; CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 Loop = 0; - bool EntryFound = false; + uint16 Loop; + bool EntryFound = false; /* Verify command packet length */ if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) diff --git a/fsw/src/cs_memory_cmds.h b/fsw/src/cs_memory_cmds.h index f8ec7d7..c5a6ed6 100644 --- a/fsw/src/cs_memory_cmds.h +++ b/fsw/src/cs_memory_cmds.h @@ -157,7 +157,6 @@ void CS_EnableEntryIDMemoryCmd(const CS_EntryCmd_t *CmdPtr); * \par Assumptions, External Events, and Notes: * None * - * * \param[in] CmdPtr Command pointer, verified non-null in CS_AppMain * * \sa #CS_GET_ENTRY_ID_MEMORY_CC diff --git a/fsw/src/cs_table_cmds.c b/fsw/src/cs_table_cmds.c index 04c3669..b0733d8 100644 --- a/fsw/src/cs_table_cmds.c +++ b/fsw/src/cs_table_cmds.c @@ -46,13 +46,19 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_DisableTablesCmd(const CS_NoArgsCmd_t *CmdPtr) { + bool Status; + /* command verification variables */ size_t ExpectedLength = sizeof(CS_NoArgsCmd_t); /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { - if (CS_CheckRecomputeOneshot() == false) + Status = CS_CheckRecomputeOneshot(); + + if (!Status) { CS_AppData.HkPacket.TablesCSState = CS_STATE_DISABLED; CS_ZeroTablesTempValues(); @@ -75,13 +81,19 @@ void CS_DisableTablesCmd(const CS_NoArgsCmd_t *CmdPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_EnableTablesCmd(const CS_NoArgsCmd_t *CmdPtr) { + bool Status; + /* command verification variables */ size_t ExpectedLength = sizeof(CS_NoArgsCmd_t); /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { - if (CS_CheckRecomputeOneshot() == false) + Status = CS_CheckRecomputeOneshot(); + + if (!Status) { CS_AppData.HkPacket.TablesCSState = CS_STATE_ENABLED; @@ -109,14 +121,19 @@ void CS_ReportBaselineTablesCmd(const CS_TableNameCmd_t *CmdPtr) CS_Res_Tables_Table_Entry_t *ResultsEntry; uint32 Baseline; char Name[CFE_TBL_MAX_FULL_NAME_LEN]; + bool Status; /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { strncpy(Name, CmdPtr->Name, sizeof(Name) - 1); Name[sizeof(Name) - 1] = '\0'; - if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) + Status = CS_GetTableResTblEntryByName(&ResultsEntry, Name); + + if (Status) { if (ResultsEntry->ComputedYet == true) { @@ -154,10 +171,13 @@ void CS_RecomputeBaselineTablesCmd(const CS_TableNameCmd_t *CmdPtr) CFE_Status_t Status; CS_Res_Tables_Table_Entry_t *ResultsEntry; char Name[CFE_TBL_MAX_FULL_NAME_LEN]; + bool Result; /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Result = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Result) { if (CS_AppData.HkPacket.RecomputeInProgress == false && CS_AppData.HkPacket.OneShotInProgress == false) { @@ -165,7 +185,9 @@ void CS_RecomputeBaselineTablesCmd(const CS_TableNameCmd_t *CmdPtr) Name[sizeof(Name) - 1] = '\0'; /* make sure the entry is a valid number and is defined in the table */ - if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) + Result = CS_GetTableResTblEntryByName(&ResultsEntry, Name); + + if (Result) { /* There is no child task running right now, we can use it*/ CS_AppData.HkPacket.RecomputeInProgress = true; @@ -222,16 +244,23 @@ void CS_DisableNameTablesCmd(const CS_TableNameCmd_t *CmdPtr) CS_Res_Tables_Table_Entry_t *ResultsEntry; CS_Def_Tables_Table_Entry_t *DefinitionEntry; char Name[CFE_TBL_MAX_FULL_NAME_LEN]; + bool Status; /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { - if (CS_CheckRecomputeOneshot() == false) + Status = CS_CheckRecomputeOneshot(); + + if (!Status) { strncpy(Name, CmdPtr->Name, sizeof(Name) - 1); Name[sizeof(Name) - 1] = '\0'; - if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) + Status = CS_GetTableResTblEntryByName(&ResultsEntry, Name); + + if (Status) { ResultsEntry->State = CS_STATE_DISABLED; ResultsEntry->TempChecksumValue = 0; @@ -240,7 +269,9 @@ void CS_DisableNameTablesCmd(const CS_TableNameCmd_t *CmdPtr) CFE_EVS_SendEvent(CS_DISABLE_TABLES_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of table %s is Disabled", Name); - if (CS_GetTableDefTblEntryByName(&DefinitionEntry, Name)) + Status = CS_GetTableDefTblEntryByName(&DefinitionEntry, Name); + + if (Status) { DefinitionEntry->State = CS_STATE_DISABLED; CS_ResetTablesTblResultEntry(CS_AppData.TblResTablesTblPtr); @@ -277,23 +308,32 @@ void CS_EnableNameTablesCmd(const CS_TableNameCmd_t *CmdPtr) CS_Res_Tables_Table_Entry_t *ResultsEntry; CS_Def_Tables_Table_Entry_t *DefinitionEntry; char Name[CFE_TBL_MAX_FULL_NAME_LEN]; + bool Status; /* Verify command packet length */ - if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) + Status = CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength); + + if (Status) { - if (CS_CheckRecomputeOneshot() == false) + Status = CS_CheckRecomputeOneshot(); + + if (!Status) { strncpy(Name, CmdPtr->Name, sizeof(Name) - 1); Name[sizeof(Name) - 1] = '\0'; - if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) + Status = CS_GetTableResTblEntryByName(&ResultsEntry, Name); + + if (Status) { ResultsEntry->State = CS_STATE_ENABLED; CFE_EVS_SendEvent(CS_ENABLE_TABLES_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of table %s is Enabled", Name); - if (CS_GetTableDefTblEntryByName(&DefinitionEntry, Name)) + Status = CS_GetTableDefTblEntryByName(&DefinitionEntry, Name); + + if (Status) { DefinitionEntry->State = CS_STATE_ENABLED; CS_ResetTablesTblResultEntry(CS_AppData.TblResTablesTblPtr); diff --git a/fsw/src/cs_table_processing.c b/fsw/src/cs_table_processing.c index 42f55af..4a8c9af 100644 --- a/fsw/src/cs_table_processing.c +++ b/fsw/src/cs_table_processing.c @@ -47,17 +47,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_ValidateEepromChecksumDefinitionTable(void *TblPtr) { - CFE_Status_t Result = CFE_SUCCESS; - CFE_Status_t Status = OS_ERROR; + CFE_Status_t Result = CFE_SUCCESS; + CFE_Status_t Status; CS_Def_EepromMemory_Table_Entry_t *StartOfTable = NULL; CS_Def_EepromMemory_Table_Entry_t *OuterEntry = NULL; - int32 OuterLoop = 0; - uint32 StateField = 0; - cpuaddr Address = 0; - uint32 Size = 0; - int32 GoodCount = 0; - int32 BadCount = 0; - int32 EmptyCount = 0; + int32 OuterLoop; + uint32 StateField; + cpuaddr Address; + uint32 Size; + int32 GoodCount = 0; + int32 BadCount = 0; + int32 EmptyCount = 0; StartOfTable = (CS_Def_EepromMemory_Table_Entry_t *)TblPtr; @@ -127,22 +127,20 @@ CFE_Status_t CS_ValidateEepromChecksumDefinitionTable(void *TblPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_ValidateMemoryChecksumDefinitionTable(void *TblPtr) { - CFE_Status_t Result = CFE_SUCCESS; - CFE_Status_t Status = OS_ERROR; + CFE_Status_t Result = CFE_SUCCESS; + CFE_Status_t Status; CS_Def_EepromMemory_Table_Entry_t *StartOfTable = NULL; CS_Def_EepromMemory_Table_Entry_t *OuterEntry = NULL; - int32 OuterLoop = 0; - uint32 StateField = 0; - cpuaddr Address = 0; - uint32 Size = 0; - int32 GoodCount = 0; - int32 BadCount = 0; - int32 EmptyCount = 0; + int32 OuterLoop; + uint32 StateField; + cpuaddr Address; + uint32 Size; + int32 GoodCount = 0; + int32 BadCount = 0; + int32 EmptyCount = 0; StartOfTable = (CS_Def_EepromMemory_Table_Entry_t *)TblPtr; - Result = CFE_SUCCESS; - for (OuterLoop = 0; OuterLoop < CS_MAX_NUM_MEMORY_TABLE_ENTRIES; OuterLoop++) { OuterEntry = &StartOfTable[OuterLoop]; @@ -211,16 +209,16 @@ CFE_Status_t CS_ValidateMemoryChecksumDefinitionTable(void *TblPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_ValidateTablesChecksumDefinitionTable(void *TblPtr) { - CFE_Status_t Result = CFE_SUCCESS; - CS_Def_Tables_Table_Entry_t *StartOfTable = NULL; - CS_Def_Tables_Table_Entry_t *OuterEntry = NULL; - int32 OuterLoop = 0; - int32 InnerLoop = 0; - uint32 StateField = 0; - int32 GoodCount = 0; - int32 BadCount = 0; - int32 EmptyCount = 0; - bool DuplicateFound = false; + CFE_Status_t Result = CFE_SUCCESS; + CS_Def_Tables_Table_Entry_t *StartOfTable = NULL; + CS_Def_Tables_Table_Entry_t *OuterEntry = NULL; + int32 OuterLoop; + int32 InnerLoop; + uint32 StateField; + int32 GoodCount = 0; + int32 BadCount = 0; + int32 EmptyCount = 0; + bool DuplicateFound; StartOfTable = (CS_Def_Tables_Table_Entry_t *)TblPtr; @@ -474,6 +472,7 @@ void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_En PreviousState = CS_AppData.HkPacket.EepromCSState; CS_AppData.HkPacket.EepromCSState = CS_STATE_DISABLED; } + if (Table == CS_MEMORY_TABLE) { PreviousState = CS_AppData.HkPacket.MemoryCSState; @@ -552,15 +551,15 @@ void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *Defin CS_Def_Tables_Table_Entry_t *DefEntry = NULL; CS_Res_Tables_Table_Entry_t *StartOfResultsTable = NULL; CS_Res_Tables_Table_Entry_t *ResultsEntry = NULL; - uint16 Loop = 0; - uint16 NumRegionsInTable = 0; - uint16 PreviousState = CS_STATE_EMPTY; - CFE_ES_AppId_t AppID = CFE_ES_APPID_UNDEFINED; - CFE_TBL_Handle_t TableHandle = CFE_TBL_BAD_TABLE_HANDLE; - bool Owned = false; - uint16 DefNameIndex = 0; - uint16 AppNameIndex = 0; - uint16 TableNameIndex = 0; + uint16 Loop; + uint16 NumRegionsInTable = 0; + uint16 PreviousState; + CFE_ES_AppId_t AppID = CFE_ES_APPID_UNDEFINED; + CFE_TBL_Handle_t TableHandle; + bool Owned; + uint16 DefNameIndex; + uint16 AppNameIndex; + uint16 TableNameIndex; char AppName[OS_MAX_API_NAME]; char TableAppName[OS_MAX_API_NAME]; char TableTableName[CFE_MISSION_TBL_MAX_NAME_LENGTH]; @@ -745,9 +744,9 @@ void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionT CS_Def_App_Table_Entry_t *DefEntry = NULL; CS_Res_App_Table_Entry_t *StartOfResultsTable = NULL; CS_Res_App_Table_Entry_t *ResultsEntry = NULL; - uint16 Loop = 0; - uint16 NumRegionsInTable = 0; - uint16 PreviousState = CS_STATE_EMPTY; + uint16 Loop; + uint16 NumRegionsInTable = 0; + uint16 PreviousState; memcpy(&StartOfResultsTable, ResultsTblPtr, sizeof(StartOfResultsTable)); memcpy(&StartOfDefTable, DefinitionTblPtr, sizeof(StartOfDefTable)); @@ -813,17 +812,17 @@ void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionT CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handle_t *ResultsTableHandle, void *DefinitionTblPtr, void *ResultsTblPtr, uint16 Table, const char *DefinitionTableName, const char *ResultsTableName, uint16 NumEntries, const char *DefinitionTableFileName, - const void *DefaultDefTableAddress, uint16 SizeofDefinitionTableEntry, - uint16 SizeofResultsTableEntry, CFE_TBL_CallbackFuncPtr_t CallBackFunction) + const void *DefaultDefTableAddress, const size_t SizeofDefinitionTableEntry, + const size_t SizeofResultsTableEntry, CFE_TBL_CallbackFuncPtr_t CallBackFunction) { - CFE_Status_t Result = CFE_SUCCESS; - int32 OS_Status = -1; - CFE_Status_t ResultFromLoad = OS_ERROR; - int32 SizeOfTable = 0; - bool LoadedFromMemory = false; - bool ValidFile = false; - osal_id_t Fd = OS_OBJECT_ID_UNDEFINED; - char TableType[CS_TABLETYPE_NAME_SIZE]; + CFE_Status_t Result; + osal_status_t OS_Status = OS_ERROR; + CFE_Status_t ResultFromLoad = CS_ERROR; + size_t SizeOfTable; + bool LoadedFromMemory = false; + bool ValidFile = false; + osal_id_t Fd = OS_OBJECT_ID_UNDEFINED; + char TableType[CS_TABLETYPE_NAME_SIZE]; strncpy(TableType, "Undef Tbl", CS_TABLETYPE_NAME_SIZE); /* Init table type */ @@ -957,14 +956,14 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl CFE_Status_t CS_HandleTableUpdate(void *DefinitionTblPtr, void *ResultsTblPtr, CFE_TBL_Handle_t DefinitionTableHandle, CFE_TBL_Handle_t ResultsTableHandle, uint16 Table, uint16 NumEntries) { - CFE_Status_t ReleaseResult1 = CFE_SUCCESS; - CFE_Status_t ManageResult1 = CFE_SUCCESS; - CFE_Status_t GetResult1 = CFE_SUCCESS; - CFE_Status_t ReleaseResult2 = CFE_SUCCESS; - CFE_Status_t ManageResult2 = CFE_SUCCESS; - CFE_Status_t GetResult2 = CFE_SUCCESS; - CFE_Status_t Result = CFE_SUCCESS; - int32 Loop = 0; + CFE_Status_t ReleaseResult1; + CFE_Status_t ManageResult1; + CFE_Status_t GetResult1; + CFE_Status_t ReleaseResult2; + CFE_Status_t ManageResult2; + CFE_Status_t GetResult2 = CFE_SUCCESS; + CFE_Status_t Result; + int32 Loop; char TableType[CS_TABLETYPE_NAME_SIZE]; strncpy(TableType, "Undef Tbl", CS_TABLETYPE_NAME_SIZE); /* Init table type */ diff --git a/fsw/src/cs_utils.c b/fsw/src/cs_utils.c index 473ce04..bf5527b 100644 --- a/fsw/src/cs_utils.c +++ b/fsw/src/cs_utils.c @@ -210,6 +210,7 @@ bool CS_GetTableResTblEntryByName(CS_Res_Tables_Table_Entry_t **EntryPtr, const break; } } + return Status; } @@ -241,6 +242,7 @@ bool CS_GetTableDefTblEntryByName(CS_Def_Tables_Table_Entry_t **EntryPtr, const break; } } + return Status; } @@ -271,6 +273,7 @@ bool CS_GetAppResTblEntryByName(CS_Res_App_Table_Entry_t **EntryPtr, const char break; } } + return Status; } @@ -301,6 +304,7 @@ bool CS_GetAppDefTblEntryByName(CS_Def_App_Table_Entry_t **EntryPtr, const char break; } } + return Status; } @@ -405,6 +409,7 @@ bool CS_FindEnabledTablesEntry(uint16 *EnabledEntry) return EnabledEntries; } + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* CS Get the next CS-enabled entry of this table */ @@ -466,6 +471,7 @@ bool CS_VerifyCmdLength(const CFE_MSG_Message_t *msg, size_t ExpectedLength) Result = false; CS_AppData.HkPacket.CmdErrCounter++; } + return Result; } @@ -617,10 +623,13 @@ bool CS_BackgroundEeprom(void) uint32 EntireEepromCS; uint16 CurrEntry; CFE_Status_t Status; + bool Result; if (CS_AppData.HkPacket.EepromCSState == CS_STATE_ENABLED) { - if (CS_FindEnabledEepromEntry(&CurrEntry) == true) + Result = CS_FindEnabledEepromEntry(&CurrEntry); + + if (Result) { /* we found an enabled entry to checksum */ StartOfResultsTable = CS_AppData.ResEepromTblPtr; @@ -690,12 +699,15 @@ bool CS_BackgroundMemory(void) uint32 ComputedCSValue = 0; uint16 CurrEntry; CFE_Status_t Status; + bool Result; if (CS_AppData.HkPacket.MemoryCSState == CS_STATE_ENABLED) { /* If we complete an entry's checksum, this function will update it for us */ - if (CS_FindEnabledMemoryEntry(&CurrEntry) == true) + Result = CS_FindEnabledMemoryEntry(&CurrEntry); + + if (Result) { /* we found an enabled entry to checksum */ StartOfResultsTable = CS_AppData.ResMemoryTblPtr; @@ -759,12 +771,15 @@ bool CS_BackgroundTables(void) uint32 ComputedCSValue = 0; uint16 CurrEntry; CFE_Status_t Status; + bool Result; if (CS_AppData.HkPacket.TablesCSState == CS_STATE_ENABLED) { /* If we complete an entry's checksum, this function will update it for us */ - if (CS_FindEnabledTablesEntry(&CurrEntry) == true) + Result = CS_FindEnabledTablesEntry(&CurrEntry); + + if (Result) { /* we found an enabled entry to checksum */ @@ -836,10 +851,13 @@ bool CS_BackgroundApp(void) uint32 ComputedCSValue = 0; uint16 CurrEntry; CFE_Status_t Status; + bool Result; if (CS_AppData.HkPacket.AppCSState == CS_STATE_ENABLED) { - if (CS_FindEnabledAppEntry(&CurrEntry) == true) + Result = CS_FindEnabledAppEntry(&CurrEntry); + + if (Result) { /* we found an enabled entry to checksum */ @@ -893,6 +911,7 @@ bool CS_BackgroundApp(void) { CS_GoToNextTable(); } + return DoneWithCycle; } @@ -919,8 +938,8 @@ void CS_ResetTablesTblResultEntry(CS_Res_Tables_Table_Entry_t *TablesTblResultEn /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_HandleRoutineTableUpdates(void) { - CFE_Status_t Result = CFE_SUCCESS; - CFE_Status_t ErrorCode = CFE_SUCCESS; + CFE_Status_t Result; + CFE_Status_t ReturnCode = CFE_SUCCESS; if (!((CS_AppData.HkPacket.RecomputeInProgress == true) && (CS_AppData.HkPacket.OneShotInProgress == false) && (CS_AppData.ChildTaskTable == CS_EEPROM_TABLE))) @@ -935,7 +954,7 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) Result = CFE_EVS_SendEvent(CS_UPDATE_EEPROM_ERR_EID, CFE_EVS_EventType_ERROR, "Table update failed for EEPROM: 0x%08X, checksumming EEPROM is disabled", (unsigned int)Result); - ErrorCode = Result; + ReturnCode = Result; } } @@ -952,9 +971,9 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) "Table update failed for Memory: 0x%08X, checksumming Memory is disabled", (unsigned int)Result); - if (ErrorCode == CFE_SUCCESS) + if (ReturnCode == CFE_SUCCESS) { - ErrorCode = Result; + ReturnCode = Result; } } } @@ -971,9 +990,9 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) Result = CFE_EVS_SendEvent(CS_UPDATE_APP_ERR_EID, CFE_EVS_EventType_ERROR, "Table update failed for Apps: 0x%08X, checksumming Apps is disabled", (unsigned int)Result); - if (ErrorCode == CFE_SUCCESS) + if (ReturnCode == CFE_SUCCESS) { - ErrorCode = Result; + ReturnCode = Result; } } } @@ -991,18 +1010,18 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) Result = CFE_EVS_SendEvent(CS_UPDATE_TABLES_ERR_EID, CFE_EVS_EventType_ERROR, "Table update failed for Tables: 0x%08X, checksumming Tables is disabled", (unsigned int)Result); - if (ErrorCode == CFE_SUCCESS) + if (ReturnCode == CFE_SUCCESS) { - ErrorCode = Result; + ReturnCode = Result; } } } - return ErrorCode; + return ReturnCode; } CFE_Status_t CS_AttemptTableReshare(CS_Res_Tables_Table_Entry_t *ResultsEntry, CFE_TBL_Handle_t *LocalTblHandle, - CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, int32 *ResultGetInfo) + CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, CFE_Status_t *ResultGetInfo) { CFE_Status_t Result; @@ -1042,5 +1061,6 @@ bool CS_CheckRecomputeOneshot(void) Result = true; } + return Result; } diff --git a/fsw/src/cs_utils.h b/fsw/src/cs_utils.h index bea8470..6c10828 100644 --- a/fsw/src/cs_utils.h +++ b/fsw/src/cs_utils.h @@ -498,7 +498,7 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void); * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS */ CFE_Status_t CS_AttemptTableReshare(CS_Res_Tables_Table_Entry_t *ResultsEntry, CFE_TBL_Handle_t *LocalTblHandle, - CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, int32 *ResultGetInfo); + CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, CFE_Status_t *ResultGetInfo); bool CS_CheckRecomputeOneshot(void); diff --git a/unit-test/stubs/cs_table_processing_stubs.c b/unit-test/stubs/cs_table_processing_stubs.c index cca9fe9..3e3acd9 100644 --- a/unit-test/stubs/cs_table_processing_stubs.c +++ b/unit-test/stubs/cs_table_processing_stubs.c @@ -92,7 +92,7 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl void *DefinitionTblPtr, void *ResultsTblPtr, const uint16 Table, const char *DefinitionTableName, const char *ResultsTableName, const uint16 NumEntries, const char *DefinitionTableFileName, const void *DefaultDefTableAddress, - const uint16 SizeofDefinitionTableEntry, const uint16 SizeofResultsTableEntry, + const size_t SizeofDefinitionTableEntry, const size_t SizeofResultsTableEntry, const CFE_TBL_CallbackFuncPtr_t CallBackFunction) { diff --git a/unit-test/stubs/cs_utils_stubs.c b/unit-test/stubs/cs_utils_stubs.c index 0e553ef..5eb1829 100644 --- a/unit-test/stubs/cs_utils_stubs.c +++ b/unit-test/stubs/cs_utils_stubs.c @@ -175,7 +175,7 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) } CFE_Status_t CS_AttemptTableReshare(CS_Res_Tables_Table_Entry_t *ResultsEntry, CFE_TBL_Handle_t *LocalTblHandle, - CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, int32 *ResultGetInfo) + CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, CFE_Status_t *ResultGetInfo) { UT_Stub_RegisterContext(UT_KEY(CS_AttemptTableReshare), ResultsEntry); UT_Stub_RegisterContext(UT_KEY(CS_AttemptTableReshare), LocalTblHandle);