Skip to content

Commit

Permalink
Merge pull request nasa#24 from skliper/fix23-rm_psp_mem_use
Browse files Browse the repository at this point in the history
Fix nasa#23, Remove CFE_PSP_MemSet and CFE_PSP_MemSet use
  • Loading branch information
astrogeco authored Jun 1, 2022
2 parents 5ed216c + 95f6f97 commit a713bda
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 145 deletions.
6 changes: 3 additions & 3 deletions fsw/src/ds_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int32 DS_AppInitialize(void)
/*
** Initialize global data structure...
*/
CFE_PSP_MemSet(&DS_AppData, 0, sizeof(DS_AppData_t));
memset(&DS_AppData, 0, sizeof(DS_AppData));

DS_AppData.AppEnableState = DS_DEF_ENABLE_STATE;

Expand Down Expand Up @@ -588,7 +588,7 @@ void DS_AppProcessHK(void)
CFE_EVS_SendEvent(DS_APPHK_FILTER_TBL_ERR_EID, CFE_EVS_EventType_ERROR,
"Invalid filter tbl name in DS_AppProcessHK. Name=%s, Err=0x%08X", FilterTblName, Status);

CFE_PSP_MemSet(HkPacket.FilterTblFilename, 0, OS_MAX_PATH_LEN);
memset(HkPacket.FilterTblFilename, 0, sizeof(HkPacket.FilterTblFilename));
}
}
else
Expand All @@ -598,7 +598,7 @@ void DS_AppProcessHK(void)
CFE_EVS_SendEvent(DS_APPHK_FILTER_TBL_PRINT_ERR_EID, CFE_EVS_EventType_ERROR,
"Filter tbl name copy fail in DS_AppProcessHK. Err=%d", (int)Status);

CFE_PSP_MemSet(HkPacket.FilterTblFilename, 0, OS_MAX_PATH_LEN);
memset(HkPacket.FilterTblFilename, 0, sizeof(HkPacket.FilterTblFilename));
}

/*
Expand Down
8 changes: 4 additions & 4 deletions fsw/src/ds_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void DS_FileWriteHeader(int32 FileIndex)
/*
** Initialize selected parts of the cFE file header...
*/
CFE_PSP_MemSet(&CFE_FS_Header, 0, sizeof(CFE_FS_Header_t));
memset(&CFE_FS_Header, 0, sizeof(CFE_FS_Header));
CFE_FS_Header.SubType = DS_FILE_HDR_SUBTYPE;
strcpy(CFE_FS_Header.Description, DS_FILE_HDR_DESCRIPTION);

Expand All @@ -417,7 +417,7 @@ void DS_FileWriteHeader(int32 FileIndex)
/*
** Initialize the DS file header...
*/
CFE_PSP_MemSet(&DS_FileHeader, 0, sizeof(DS_FileHeader_t));
memset(&DS_FileHeader, 0, sizeof(DS_FileHeader));
DS_FileHeader.FileTableIndex = FileIndex;
DS_FileHeader.FileNameType = DestFile->FileNameType;
strcpy(DS_FileHeader.FileName, FileStatus->FileName);
Expand Down Expand Up @@ -519,7 +519,7 @@ void DS_FileCreateDest(uint32 FileIndex)
"FILE CREATE error: result = %d, dest = %d, name = '%s'", (int)Result, (int)FileIndex,
FileStatus->FileName);

CFE_PSP_MemSet(FileStatus->FileName, 0, DS_TOTAL_FNAME_BUFSIZE);
memset(FileStatus->FileName, 0, sizeof(FileStatus->FileName));

/*
** Something needs to get fixed before we try again...
Expand Down Expand Up @@ -977,7 +977,7 @@ void DS_FileCloseDest(int32 FileIndex)
/*
** Remove previous filename from status data...
*/
CFE_PSP_MemSet(FileStatus->FileName, 0, DS_TOTAL_FNAME_BUFSIZE);
memset(FileStatus->FileName, 0, sizeof(FileStatus->FileName));

return;

Expand Down
4 changes: 2 additions & 2 deletions fsw/src/ds_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,8 @@ void DS_TableCreateHash(void)
/*
** Initialize global hash table structures...
*/
CFE_PSP_MemSet(DS_AppData.HashLinks, 0, (sizeof(DS_HashLink_t) * DS_PACKETS_IN_FILTER_TABLE));
CFE_PSP_MemSet(DS_AppData.HashTable, 0, (sizeof(DS_HashLink_t *) * DS_HASH_TABLE_ENTRIES));
memset(DS_AppData.HashLinks, 0, sizeof(DS_AppData.HashLinks));
memset(DS_AppData.HashTable, 0, sizeof(DS_AppData.HashTable));

for (FilterIndex = 0; FilterIndex < DS_PACKETS_IN_FILTER_TABLE; FilterIndex++)
{
Expand Down
12 changes: 6 additions & 6 deletions unit-test/ds_app_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void DS_AppInitialize_Test_Nominal(void)
snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH,
"Application initialized, version %%d.%%d.%%d.%%d, data at %%p");

CFE_PSP_MemSet(&DS_AppData, 1, sizeof(DS_AppData_t));
memset(&DS_AppData, 1, sizeof(DS_AppData));

/* Execute the function being tested */
Result = DS_AppInitialize();
Expand All @@ -215,7 +215,7 @@ void DS_AppInitialize_Test_Nominal(void)
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle));
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileHandle));

/* Note: not verifying that CFE_PSP_MemSet set the rest of DS_AppData to 0, because some elements of DS_AppData
/* Note: not verifying the rest of DS_AppData is set to 0, because some elements of DS_AppData
* are modified by subfunctions, which we're not testing here */

UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS");
Expand Down Expand Up @@ -250,7 +250,7 @@ void DS_AppInitialize_Test_EVSRegisterError(void)
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle));
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileHandle));

/* Note: not verifying that CFE_PSP_MemSet set the rest of DS_AppData to 0, because some elements of DS_AppData
/* Note: not verifying that rest of DS_AppData is set to 0, because some elements of DS_AppData
* are modified by subfunctions, which we're not testing here */
/*
UtAssert_True
Expand Down Expand Up @@ -281,7 +281,7 @@ void DS_AppInitialize_Test_SBCreatePipeError(void)
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle));
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileHandle));

/* Note: not verifying that CFE_PSP_MemSet set the rest of DS_AppData to 0, because some elements of DS_AppData
/* Note: not verifying that the rest of DS_AppData is set to 0, because some elements of DS_AppData
* are modified by subfunctions, which we're not testing here */

/*UtAssert_True
Expand Down Expand Up @@ -313,7 +313,7 @@ void DS_AppInitialize_Test_SBSubscribeHKError(void)
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle));
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileHandle));

/* Note: not verifying that CFE_PSP_MemSet set the rest of DS_AppData to 0, because some elements of DS_AppData
/* Note: not verifying that the rest of DS_AppData is set to 0, because some elements of DS_AppData
* are modified by subfunctions, which we're not testing here */
/*
UtAssert_True
Expand Down Expand Up @@ -345,7 +345,7 @@ void DS_AppInitialize_Test_SBSubscribeDSError(void)
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle));
UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileHandle));

/* Note: not verifying that CFE_PSP_MemSet set the rest of DS_AppData to 0, because some elements of DS_AppData
/* Note: not verifying that the rest of DS_AppData is set to 0, because some elements of DS_AppData
* are modified by subfunctions, which we're not testing here */

/* UtAssert_True
Expand Down
Loading

0 comments on commit a713bda

Please sign in to comment.