diff --git a/fsw/src/fm_app.c b/fsw/src/fm_app.c index a00def3..8566424 100644 --- a/fsw/src/fm_app.c +++ b/fsw/src/fm_app.c @@ -65,7 +65,7 @@ void FM_AppMain(void) { uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; CFE_SB_Buffer_t *BufPtr = NULL; - int32 Result = CFE_SUCCESS; + int32 Result; /* Performance Log (start time counter) */ CFE_ES_PerfLogEntry(FM_APPMAIN_PERF_ID); @@ -167,7 +167,7 @@ void FM_AppMain(void) int32 FM_AppInit(void) { const char *ErrText = "Initialization error:"; - int32 Result = CFE_SUCCESS; + int32 Result; /* Initialize global data */ memset(&FM_GlobalData, 0, sizeof(FM_GlobalData)); @@ -390,7 +390,7 @@ void FM_ProcessCmd(const CFE_SB_Buffer_t *BufPtr) void FM_SendHkCmd(const CFE_SB_Buffer_t *BufPtr) { const char * CmdText = "HK Request"; - bool Result = true; + bool Result; FM_HousekeepingPkt_Payload_t *PayloadPtr; /* Verify command packet length */ diff --git a/fsw/src/fm_child.c b/fsw/src/fm_child.c index facf538..21f1eee 100644 --- a/fsw/src/fm_child.c +++ b/fsw/src/fm_child.c @@ -58,8 +58,8 @@ int32 FM_ChildInit(void) { int32 TaskTextLen = OS_MAX_PATH_LEN; char TaskText[OS_MAX_PATH_LEN] = "\0"; - int32 Result = CFE_SUCCESS; - uint32 TaskEID = 0; + int32 Result; + uint32 TaskEID = 0; /* Create counting semaphore (given by parent to wake-up child) */ Result = OS_CountSemCreate(&FM_GlobalData.ChildSemaphore, FM_CHILD_SEM_NAME, 0, 0); @@ -279,8 +279,8 @@ void FM_ChildProcess(void) void FM_ChildCopyCmd(const FM_ChildQueueEntry_t *CmdArgs) { - const char *CmdText = "Copy File"; - int32 OS_Status = OS_SUCCESS; + const char *CmdText = "Copy File"; + int32 OS_Status; /* Report current child task activity */ FM_GlobalData.ChildCurrentCC = CmdArgs->CommandCode; @@ -319,8 +319,8 @@ void FM_ChildCopyCmd(const FM_ChildQueueEntry_t *CmdArgs) void FM_ChildMoveCmd(const FM_ChildQueueEntry_t *CmdArgs) { - const char *CmdText = "Move File"; - int32 OS_Status = OS_SUCCESS; + const char *CmdText = "Move File"; + int32 OS_Status; /* Report current child task activity */ FM_GlobalData.ChildCurrentCC = CmdArgs->CommandCode; @@ -358,8 +358,8 @@ void FM_ChildMoveCmd(const FM_ChildQueueEntry_t *CmdArgs) void FM_ChildRenameCmd(const FM_ChildQueueEntry_t *CmdArgs) { - const char *CmdText = "Rename File"; - int32 OS_Status = OS_SUCCESS; + const char *CmdText = "Rename File"; + int32 OS_Status; /* Report current child task activity */ FM_GlobalData.ChildCurrentCC = CmdArgs->CommandCode; @@ -397,8 +397,8 @@ void FM_ChildRenameCmd(const FM_ChildQueueEntry_t *CmdArgs) void FM_ChildDeleteCmd(const FM_ChildQueueEntry_t *CmdArgs) { - const char *CmdText = "Delete File"; - int32 OS_Status = OS_SUCCESS; + const char *CmdText = "Delete File"; + int32 OS_Status; /* Report current child task activity */ FM_GlobalData.ChildCurrentCC = CmdArgs->CommandCode; @@ -439,7 +439,7 @@ void FM_ChildDeleteAllFilesCmd(FM_ChildQueueEntry_t *CmdArgs) const char *CmdText = "Delete All Files"; osal_id_t DirId = OS_OBJECT_ID_UNDEFINED; os_dirent_t DirEntry; - int32 OS_Status = OS_SUCCESS; + int32 OS_Status; uint32 FilenameState = FM_NAME_IS_INVALID; uint32 NameLength = 0; uint32 DeleteCount = 0; @@ -587,8 +587,8 @@ void FM_ChildDeleteAllFilesCmd(FM_ChildQueueEntry_t *CmdArgs) void FM_ChildDecompressFileCmd(const FM_ChildQueueEntry_t *CmdArgs) { - const char *CmdText = "Decompress File"; - int32 CFE_Status = CFE_SUCCESS; + const char *CmdText = "Decompress File"; + int32 CFE_Status; /* Report current child task activity */ FM_GlobalData.ChildCurrentCC = CmdArgs->CommandCode; @@ -634,11 +634,11 @@ void FM_ChildConcatFilesCmd(const FM_ChildQueueEntry_t *CmdArgs) bool OpenedSource2 = false; bool OpenedTgtFile = false; int32 LoopCount = 0; - int32 OS_Status = OS_SUCCESS; - osal_id_t FileHandleSrc = OS_OBJECT_ID_UNDEFINED; - osal_id_t FileHandleTgt = OS_OBJECT_ID_UNDEFINED; - int32 BytesRead = 0; - int32 BytesWritten = 0; + int32 OS_Status; + osal_id_t FileHandleSrc = OS_OBJECT_ID_UNDEFINED; + osal_id_t FileHandleTgt = OS_OBJECT_ID_UNDEFINED; + int32 BytesRead = 0; + int32 BytesWritten = 0; /* Report current child task activity */ FM_GlobalData.ChildCurrentCC = CmdArgs->CommandCode; @@ -963,8 +963,8 @@ void FM_ChildFileInfoCmd(FM_ChildQueueEntry_t *CmdArgs) void FM_ChildCreateDirectoryCmd(const FM_ChildQueueEntry_t *CmdArgs) { - const char *CmdText = "Create Directory"; - int32 OS_Status = OS_SUCCESS; + const char *CmdText = "Create Directory"; + int32 OS_Status; /* Report current child task activity */ FM_GlobalData.ChildCurrentCC = CmdArgs->CommandCode; @@ -1006,7 +1006,7 @@ void FM_ChildDeleteDirectoryCmd(const FM_ChildQueueEntry_t *CmdArgs) bool RemoveTheDir = true; osal_id_t DirId = OS_OBJECT_ID_UNDEFINED; os_dirent_t DirEntry; - int32 OS_Status = OS_SUCCESS; + int32 OS_Status; memset(&DirEntry, 0, sizeof(DirEntry)); @@ -1080,11 +1080,11 @@ void FM_ChildDeleteDirectoryCmd(const FM_ChildQueueEntry_t *CmdArgs) void FM_ChildDirListFileCmd(const FM_ChildQueueEntry_t *CmdArgs) { - const char *CmdText = "Directory List to File"; - bool Result = false; + const char *CmdText = "Directory List to File"; + bool Result; osal_id_t FileHandle = OS_OBJECT_ID_UNDEFINED; osal_id_t DirId = OS_OBJECT_ID_UNDEFINED; - int32 Status = 0; + int32 Status; /* Report current child task activity */ FM_GlobalData.ChildCurrentCC = CmdArgs->CommandCode; @@ -1142,12 +1142,12 @@ void FM_ChildDirListPktCmd(const FM_ChildQueueEntry_t *CmdArgs) { const char * CmdText = "Directory List to Packet"; char LogicalName[OS_MAX_PATH_LEN] = "\0"; - bool StillProcessing = true; - osal_id_t DirId = OS_OBJECT_ID_UNDEFINED; + bool StillProcessing; + osal_id_t DirId = OS_OBJECT_ID_UNDEFINED; os_dirent_t DirEntry; - int32 ListIndex = 0; - FM_DirListEntry_t *ListEntry = NULL; - int32 PathLength = 0; + int32 ListIndex = 0; + FM_DirListEntry_t *ListEntry = NULL; + int32 PathLength; int32 EntryLength = 0; int32 FilesTillSleep = FM_CHILD_STAT_SLEEP_FILECOUNT; int32 Status; @@ -1275,8 +1275,8 @@ void FM_ChildDirListPktCmd(const FM_ChildQueueEntry_t *CmdArgs) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void FM_ChildSetPermissionsCmd(const FM_ChildQueueEntry_t *CmdArgs) { - int32 OS_Status = OS_SUCCESS; - const char *CmdText = "Set Permissions"; + int32 OS_Status; + const char *CmdText = "Set Permissions"; OS_Status = OS_chmod(CmdArgs->Source1, CmdArgs->Mode); @@ -1316,7 +1316,7 @@ bool FM_ChildDirListFileInit(osal_id_t *FileHandlePtr, const char *Directory, co CFE_FS_Header_t FileHeader; osal_id_t FileHandle = OS_OBJECT_ID_UNDEFINED; int32 BytesWritten = 0; - int32 Status = 0; + int32 Status; /* Initialize the standard cFE File Header for the Directory Listing File */ CFE_FS_InitHeader(&FileHeader, CmdText, FM_DIR_LIST_FILE_SUBTYPE); @@ -1392,17 +1392,17 @@ bool FM_ChildDirListFileInit(osal_id_t *FileHandlePtr, const char *Directory, co void FM_ChildDirListFileLoop(osal_id_t DirId, osal_id_t FileHandle, const char *Directory, const char *DirWithSep, const char *Filename, uint8 getSizeTimeMode) { - const char * CmdText = "Directory List to File"; - int32 WriteLength = sizeof(FM_DirListEntry_t); - bool ReadingDirectory = true; - bool CommandResult = true; - uint32 DirEntries = 0; - uint32 FileEntries = 0; - int32 EntryLength = 0; - int32 PathLength = 0; - int32 BytesWritten = 0; - int32 FilesTillSleep = FM_CHILD_STAT_SLEEP_FILECOUNT; - int32 Status = 0; + const char * CmdText = "Directory List to File"; + int32 WriteLength = sizeof(FM_DirListEntry_t); + bool ReadingDirectory = true; + bool CommandResult = true; + uint32 DirEntries = 0; + uint32 FileEntries = 0; + int32 EntryLength = 0; + int32 PathLength; + int32 BytesWritten = 0; + int32 FilesTillSleep = FM_CHILD_STAT_SLEEP_FILECOUNT; + int32 Status; char TempName[OS_MAX_PATH_LEN] = "\0"; os_dirent_t DirEntry; FM_DirListEntry_t DirListData; @@ -1529,7 +1529,7 @@ void FM_ChildDirListFileLoop(osal_id_t DirId, osal_id_t FileHandle, const char * int32 FM_ChildSizeTimeMode(const char *Filename, uint32 *FileSize, uint32 *FileTime, uint32 *FileMode) { - int32 Result = OS_SUCCESS; + int32 Result; os_fstat_t FileStatus; memset(&FileStatus, 0, sizeof(FileStatus)); diff --git a/fsw/src/fm_cmd_utils.c b/fsw/src/fm_cmd_utils.c index 532dadd..7c68137 100644 --- a/fsw/src/fm_cmd_utils.c +++ b/fsw/src/fm_cmd_utils.c @@ -273,10 +273,10 @@ uint32 FM_VerifyNameValid(const char *Name, uint32 BufferSize, uint32 EventID, c bool FM_VerifyFileState(FM_File_States State, const char *Filename, uint32 BufferSize, uint32 EventID, const char *CmdText) { - bool Result = false; - uint32 FilenameState = FM_NAME_IS_INVALID; - uint32 ErrorCode = FM_FNAME_INVALID_EID_OFFSET; - const char *ErrorDesc = ""; + bool Result = false; + uint32 FilenameState; + uint32 ErrorCode = FM_FNAME_INVALID_EID_OFFSET; + const char *ErrorDesc = ""; char LocalFile[1 + OS_MAX_PATH_LEN]; /* Get state of the filename */ @@ -532,9 +532,7 @@ void FM_AppendPathSep(char *Directory, uint32 BufferSize) ** the string is both non-zero and less than the size ** of the string buffer. */ - uint32 StringLength = 0; - - StringLength = strlen(Directory); + uint32 StringLength = strlen(Directory); /* Do nothing if string already ends with a path separator */ if ((StringLength != 0) && (Directory[StringLength - 1] != '/')) diff --git a/fsw/src/fm_cmds.c b/fsw/src/fm_cmds.c index 84b6f42..4e6cdf9 100644 --- a/fsw/src/fm_cmds.c +++ b/fsw/src/fm_cmds.c @@ -55,8 +55,8 @@ bool FM_NoopCmd(const CFE_SB_Buffer_t *BufPtr) { - const char *CmdText = "No-op"; - bool CommandResult = false; + const char *CmdText = "No-op"; + bool CommandResult; /* Verify message length */ CommandResult = FM_IsValidCmdPktLength(&BufPtr->Msg, sizeof(FM_NoopCmd_t), FM_NOOP_PKT_ERR_EID, CmdText); @@ -79,8 +79,8 @@ bool FM_NoopCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) { - const char *CmdText = "Reset Counters"; - bool CommandResult = false; + const char *CmdText = "Reset Counters"; + bool CommandResult; /* Verify message length */ CommandResult = FM_IsValidCmdPktLength(&BufPtr->Msg, sizeof(FM_ResetCountersCmd_t), FM_RESET_PKT_ERR_EID, CmdText); @@ -110,9 +110,9 @@ bool FM_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_CopyFileCmd(const CFE_SB_Buffer_t *BufPtr) { - FM_ChildQueueEntry_t *CmdArgs = NULL; - const char * CmdText = "Copy File"; - bool CommandResult = false; + FM_ChildQueueEntry_t *CmdArgs = NULL; + const char * CmdText = "Copy File"; + bool CommandResult; const FM_OvwSourceTargetFilename_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_CopyFileCmd_t); @@ -178,9 +178,9 @@ bool FM_CopyFileCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_MoveFileCmd(const CFE_SB_Buffer_t *BufPtr) { - FM_ChildQueueEntry_t *CmdArgs = NULL; - const char * CmdText = "Move File"; - bool CommandResult = false; + FM_ChildQueueEntry_t *CmdArgs = NULL; + const char * CmdText = "Move File"; + bool CommandResult; const FM_OvwSourceTargetFilename_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_MoveFileCmd_t); @@ -247,9 +247,9 @@ bool FM_MoveFileCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_RenameFileCmd(const CFE_SB_Buffer_t *BufPtr) { - FM_ChildQueueEntry_t *CmdArgs = NULL; - const char * CmdText = "Rename File"; - bool CommandResult = false; + FM_ChildQueueEntry_t *CmdArgs = NULL; + const char * CmdText = "Rename File"; + bool CommandResult; const FM_SourceTargetFileName_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_RenameFileCmd_t); @@ -303,9 +303,9 @@ bool FM_RenameFileCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_DeleteFileCmd(const CFE_SB_Buffer_t *BufPtr) { - FM_ChildQueueEntry_t *CmdArgs = NULL; - const char * CmdText = "Delete File"; - bool CommandResult = false; + FM_ChildQueueEntry_t *CmdArgs = NULL; + const char * CmdText = "Delete File"; + bool CommandResult; const FM_SingleFilename_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_DeleteFileCmd_t); @@ -353,7 +353,7 @@ bool FM_DeleteAllFilesCmd(const CFE_SB_Buffer_t *BufPtr) const char * CmdText = "Delete All Files"; char DirWithSep[OS_MAX_PATH_LEN] = "\0"; FM_ChildQueueEntry_t *CmdArgs = NULL; - bool CommandResult = false; + bool CommandResult; const FM_DirectoryName_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_DeleteAllFilesCmd_t); @@ -407,9 +407,9 @@ bool FM_DeleteAllFilesCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_DecompressFileCmd(const CFE_SB_Buffer_t *BufPtr) { - const char * CmdText = "Decompress File"; - FM_ChildQueueEntry_t *CmdArgs = NULL; - bool CommandResult = false; + const char * CmdText = "Decompress File"; + FM_ChildQueueEntry_t *CmdArgs = NULL; + bool CommandResult; const FM_SourceTargetFileName_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_DecompressFileCmd_t); @@ -461,9 +461,9 @@ bool FM_DecompressFileCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_ConcatFilesCmd(const CFE_SB_Buffer_t *BufPtr) { - const char * CmdText = "Concat Files"; - FM_ChildQueueEntry_t *CmdArgs = NULL; - bool CommandResult = false; + const char * CmdText = "Concat Files"; + FM_ChildQueueEntry_t *CmdArgs = NULL; + bool CommandResult; const FM_TwoSourceOneTarget_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_ConcatFilesCmd_t); @@ -523,9 +523,9 @@ bool FM_ConcatFilesCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_GetFileInfoCmd(const CFE_SB_Buffer_t *BufPtr) { - const char * CmdText = "Get File Info"; - FM_ChildQueueEntry_t *CmdArgs = NULL; - bool CommandResult = false; + const char * CmdText = "Get File Info"; + FM_ChildQueueEntry_t *CmdArgs = NULL; + bool CommandResult; uint32 FilenameState = FM_NAME_IS_INVALID; const FM_FilenameAndCRC_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_GetFileInfoCmd_t); @@ -585,9 +585,9 @@ bool FM_GetFileInfoCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_GetOpenFilesCmd(const CFE_SB_Buffer_t *BufPtr) { - const char *CmdText = "Get Open Files"; - bool CommandResult = false; - uint32 NumOpenFiles = 0; + const char *CmdText = "Get Open Files"; + bool CommandResult; + uint32 NumOpenFiles; FM_OpenFilesPkt_Payload_t *ReportPtr = &FM_GlobalData.OpenFilesPkt.Payload; @@ -624,9 +624,9 @@ bool FM_GetOpenFilesCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_CreateDirectoryCmd(const CFE_SB_Buffer_t *BufPtr) { - FM_ChildQueueEntry_t *CmdArgs = NULL; - const char * CmdText = "Create Directory"; - bool CommandResult = false; + FM_ChildQueueEntry_t *CmdArgs = NULL; + const char * CmdText = "Create Directory"; + bool CommandResult; const FM_DirectoryName_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_CreateDirectoryCmd_t); @@ -672,9 +672,9 @@ bool FM_CreateDirectoryCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_DeleteDirectoryCmd(const CFE_SB_Buffer_t *BufPtr) { - FM_ChildQueueEntry_t *CmdArgs = NULL; - const char * CmdText = "Delete Directory"; - bool CommandResult = false; + FM_ChildQueueEntry_t *CmdArgs = NULL; + const char * CmdText = "Delete Directory"; + bool CommandResult; const FM_DirectoryName_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_DeleteDirectoryCmd_t); @@ -724,7 +724,7 @@ bool FM_GetDirListFileCmd(const CFE_SB_Buffer_t *BufPtr) char DirWithSep[OS_MAX_PATH_LEN] = "\0"; char Filename[OS_MAX_PATH_LEN] = "\0"; FM_ChildQueueEntry_t *CmdArgs = NULL; - bool CommandResult = false; + bool CommandResult; const FM_GetDirectoryToFile_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_GetDirListFileCmd_t); @@ -803,7 +803,7 @@ bool FM_GetDirListPktCmd(const CFE_SB_Buffer_t *BufPtr) const char * CmdText = "Directory List to Packet"; char DirWithSep[OS_MAX_PATH_LEN] = "\0"; FM_ChildQueueEntry_t *CmdArgs = NULL; - bool CommandResult = false; + bool CommandResult; const FM_GetDirectoryToPkt_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_GetDirListPktCmd_t); @@ -859,9 +859,9 @@ bool FM_GetDirListPktCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_MonitorFilesystemSpaceCmd(const CFE_SB_Buffer_t *BufPtr) { - const char *CmdText = "Get Free Space"; - bool CommandResult = false; - uint32 i = 0; + const char *CmdText = "Get Free Space"; + bool CommandResult; + uint32 i = 0; int32 OpResult; const FM_MonitorTableEntry_t *MonitorPtr; @@ -953,8 +953,8 @@ bool FM_MonitorFilesystemSpaceCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_SetTableStateCmd(const CFE_SB_Buffer_t *BufPtr) { - const char *CmdText = "Set Table State"; - bool CommandResult = false; + const char *CmdText = "Set Table State"; + bool CommandResult; const FM_TableIndexAndState_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_SetTableStateCmd_t); @@ -1024,10 +1024,10 @@ bool FM_SetTableStateCmd(const CFE_SB_Buffer_t *BufPtr) bool FM_SetPermissionsCmd(const CFE_SB_Buffer_t *BufPtr) { - FM_ChildQueueEntry_t *CmdArgs = NULL; - const char * CmdText = "Set Permissions"; - bool CommandResult = false; - bool FilenameState = FM_NAME_IS_INVALID; + FM_ChildQueueEntry_t *CmdArgs = NULL; + const char * CmdText = "Set Permissions"; + bool CommandResult; + bool FilenameState; const FM_FilenameAndMode_Payload_t *CmdPtr = FM_GET_CMD_PAYLOAD(BufPtr, FM_SetPermissionsCmd_t); diff --git a/unit-test/fm_child_tests.c b/unit-test/fm_child_tests.c index 5233524..54179c7 100644 --- a/unit-test/fm_child_tests.c +++ b/unit-test/fm_child_tests.c @@ -1683,9 +1683,11 @@ void Test_FM_ChildDirListPktCmd_DirListOffsetNotExceeded(void) FM_DirListPkt_Payload_t *ReportPtr; /* Arrange */ - FM_ChildQueueEntry_t queue_entry = { - .CommandCode = FM_GET_DIR_LIST_PKT_CC, .Source1 = "dummy_source1", .Source2 = "dummy_source2", .DirListOffset = 1}; - os_dirent_t direntry = {.FileName = "filename"}; + FM_ChildQueueEntry_t queue_entry = {.CommandCode = FM_GET_DIR_LIST_PKT_CC, + .Source1 = "dummy_source1", + .Source2 = "dummy_source2", + .DirListOffset = 1}; + os_dirent_t direntry = {.FileName = "filename"}; UT_SetDeferredRetcode(UT_KEY(OS_DirectoryRead), 2, !OS_SUCCESS); UT_SetDataBuffer(UT_KEY(OS_DirectoryRead), &direntry, sizeof(direntry), false);