Skip to content

Commit

Permalink
Fix #84, Remove superfluous assignments at the top of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Mar 12, 2023
1 parent 9d3daa7 commit 7368127
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 103 deletions.
6 changes: 3 additions & 3 deletions fsw/src/fm_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 */
Expand Down
88 changes: 44 additions & 44 deletions fsw/src/fm_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
12 changes: 5 additions & 7 deletions fsw/src/fm_cmd_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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] != '/'))
Expand Down
Loading

0 comments on commit 7368127

Please sign in to comment.