Skip to content

Commit

Permalink
Merge pull request #30 from skliper/fix29-rm_psp_mem
Browse files Browse the repository at this point in the history
Fix #29, Remove CFE_PSP_MemSet use on RAM
  • Loading branch information
astrogeco authored Jun 1, 2022
2 parents e5295ad + 7364f76 commit 1c1c1ad
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion fsw/src/fm_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ int32 FM_AppInit(void)
int32 Result = CFE_SUCCESS;

/* Initialize global data */
CFE_PSP_MemSet(&FM_GlobalData, 0, sizeof(FM_GlobalData_t));
memset(&FM_GlobalData, 0, sizeof(FM_GlobalData));

/* Register for event services */
Result = CFE_EVS_Register(NULL, 0, CFE_EVS_EventFilter_BINARY);
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/fm_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ bool FM_ChildDirListFileInit(osal_id_t *FileHandlePtr, const char *Directory, co
int32 Status = 0;

/* Initialize the standard cFE File Header for the Directory Listing File */
CFE_PSP_MemSet(&FileHeader, 0, sizeof(CFE_FS_Header_t));
memset(&FileHeader, 0, sizeof(FileHeader));
FileHeader.SubType = FM_DIR_LIST_FILE_SUBTYPE;
strncpy(FileHeader.Description, CmdText, sizeof(FileHeader.Description) - 1);
FileHeader.Description[sizeof(FileHeader.Description) - 1] = '\0';
Expand All @@ -1391,7 +1391,7 @@ bool FM_ChildDirListFileInit(osal_id_t *FileHandlePtr, const char *Directory, co
if (BytesWritten == sizeof(CFE_FS_Header_t))
{
/* Initialize directory statistics structure */
CFE_PSP_MemSet(&FM_GlobalData.DirListFileStats, 0, sizeof(FM_DirListFileStats_t));
memset(&FM_GlobalData.DirListFileStats, 0, sizeof(FM_GlobalData.DirListFileStats));
strncpy(FM_GlobalData.DirListFileStats.DirName, Directory, OS_MAX_PATH_LEN - 1);
FM_GlobalData.DirListFileStats.DirName[OS_MAX_PATH_LEN - 1] = '\0';

Expand Down Expand Up @@ -1589,7 +1589,7 @@ int32 FM_ChildSizeTimeMode(const char *Filename, uint32 *FileSize, uint32 *FileT
int32 Result = OS_SUCCESS;
os_fstat_t FileStatus;

memset(&FileStatus, 0, sizeof(os_fstat_t));
memset(&FileStatus, 0, sizeof(FileStatus));

Result = OS_stat(Filename, &FileStatus);

Expand Down
2 changes: 1 addition & 1 deletion fsw/src/fm_cmd_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ bool FM_VerifyChildTask(uint32 EventID, const char *CmdText)
}
else
{
CFE_PSP_MemSet(&FM_GlobalData.ChildQueue[FM_GlobalData.ChildWriteIndex], 0, sizeof(FM_ChildQueueEntry_t));
memset(&FM_GlobalData.ChildQueue[FM_GlobalData.ChildWriteIndex], 0, sizeof(FM_GlobalData.ChildQueue[0]));

/* OK to add another command to the queue */
Result = true;
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/fm_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,12 +736,12 @@ bool FM_GetDirListFileCmd(const CFE_SB_Buffer_t *BufPtr)
/* Use default filename if not specified in the command */
if (CmdPtr->Filename[0] == '\0')
{
strncpy(Filename, FM_DIR_LIST_FILE_DEFNAME, OS_MAX_PATH_LEN - 1);
Filename[OS_MAX_PATH_LEN - 1] = '\0';
strncpy(Filename, FM_DIR_LIST_FILE_DEFNAME, sizeof(Filename) - 1);
Filename[sizeof(Filename) - 1] = '\0';
}
else
{
CFE_PSP_MemCpy(Filename, CmdPtr->Filename, OS_MAX_PATH_LEN);
memcpy(Filename, CmdPtr->Filename, sizeof(Filename));
}

/* Note: it is OK for this file to overwrite a previous version of the file */
Expand Down
6 changes: 0 additions & 6 deletions unit-test/fm_child_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3003,14 +3003,12 @@ void Test_FM_ChildDirListFileInit_OSWriteSameSizeDirListFileStatst(void)
uint8 count_osclose = UT_GetStubCount(UT_KEY(OS_close));
uint8 count_fswriteheader = UT_GetStubCount(UT_KEY(CFE_FS_WriteHeader));
uint8 count_oswrite = UT_GetStubCount(UT_KEY(OS_write));
uint8 count_pspmemset = UT_GetStubCount(UT_KEY(CFE_PSP_MemSet));

// Assert
UtAssert_INT32_EQ(result, true);
UtAssert_INT32_EQ(count_sendevent, 0);
UtAssert_INT32_EQ(count_osopencreate, 1);
UtAssert_INT32_EQ(count_fswriteheader, 1);
UtAssert_INT32_EQ(count_pspmemset, 2);
UtAssert_INT32_EQ(count_oswrite, 1);
UtAssert_INT32_EQ(count_osclose, 0);
UtAssert_INT32_EQ(count_childcmderrcounter_before, count_childcmderrcounter_after);
Expand Down Expand Up @@ -3346,10 +3344,6 @@ void Test_FM_ChildSizeTimeMode_OsStatNoSuccess(void)
uint32 dummy_filemode = UT_Utils_Any_uint32();

UT_SetDefaultReturnValue(UT_KEY(OS_stat), !OS_SUCCESS);
OS_time_t dummy_ostime = {.ticks = UT_Utils_Any_int32()};
os_fstat_t dummy_filestatus = {
.FileModeBits = UT_Utils_Any_uint32(), .FileTime = dummy_ostime, .FileSize = UT_Utils_Any_uint32()};
UT_SetDataBuffer(UT_KEY(CFE_PSP_MemSet), &dummy_filestatus, sizeof(dummy_filestatus), false);

// Act
int32 result = FM_ChildSizeTimeMode(dummy_filename, &dummy_filesize, &dummy_filetime, &dummy_filemode);
Expand Down
12 changes: 0 additions & 12 deletions unit-test/fm_cmd_utils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,9 @@ void Test_FM_VerifyChildTask_ChildSemaphoreIsInvalid(void)
bool result_verifychildtask = FM_VerifyChildTask(dummy_eventid, dummy_textptr);

uint8 count_sendevent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));
uint8 count_pspmemset = UT_GetStubCount(UT_KEY(CFE_PSP_MemSet));

// Assert
UtAssert_INT32_EQ(result_verifychildtask, false);
UtAssert_INT32_EQ(count_pspmemset, 0);
UtAssert_INT32_EQ(count_sendevent, 1);
UtAssert_INT32_EQ(dummy_eventid + FM_CHILD_DISABLED_EID_OFFSET, context_CFE_EVS_SendEvent[0].EventID);
UtAssert_INT32_EQ(CFE_EVS_EventType_ERROR, context_CFE_EVS_SendEvent[0].EventType);
Expand All @@ -690,11 +688,9 @@ void Test_FM_VerifyChildTask_LocalQueueCountEqualToQueueDepth(void)
bool result_verifychildtask = FM_VerifyChildTask(dummy_eventid, dummy_textptr);

uint8 count_sendevent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));
uint8 count_pspmemset = UT_GetStubCount(UT_KEY(CFE_PSP_MemSet));

// Assert
UtAssert_INT32_EQ(result_verifychildtask, false);
UtAssert_INT32_EQ(count_pspmemset, 0);
UtAssert_INT32_EQ(count_sendevent, 1);
UtAssert_INT32_EQ(dummy_eventid + FM_CHILD_Q_FULL_EID_OFFSET, context_CFE_EVS_SendEvent[0].EventID);
UtAssert_INT32_EQ(CFE_EVS_EventType_ERROR, context_CFE_EVS_SendEvent[0].EventType);
Expand All @@ -712,11 +708,9 @@ void Test_FM_VerifyChildTask_LocalQueueCountGreaterQueueDepth(void)
bool result_verifychildtask = FM_VerifyChildTask(dummy_eventid, dummy_textptr);

uint8 count_sendevent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));
uint8 count_pspmemset = UT_GetStubCount(UT_KEY(CFE_PSP_MemSet));

// Assert
UtAssert_INT32_EQ(result_verifychildtask, false);
UtAssert_INT32_EQ(count_pspmemset, 0);
UtAssert_INT32_EQ(count_sendevent, 1);
UtAssert_INT32_EQ(dummy_eventid + FM_CHILD_BROKEN_EID_OFFSET, context_CFE_EVS_SendEvent[0].EventID);
UtAssert_INT32_EQ(CFE_EVS_EventType_ERROR, context_CFE_EVS_SendEvent[0].EventType);
Expand All @@ -735,11 +729,9 @@ void Test_FM_VerifyChildTask_ChildWriteIndexGreaterChildQDepth(void)
bool result_verifychildtask = FM_VerifyChildTask(dummy_eventid, dummy_textptr);

uint8 count_sendevent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));
uint8 count_pspmemset = UT_GetStubCount(UT_KEY(CFE_PSP_MemSet));

// Assert
UtAssert_INT32_EQ(result_verifychildtask, false);
UtAssert_INT32_EQ(count_pspmemset, 0);
UtAssert_INT32_EQ(count_sendevent, 1);
UtAssert_INT32_EQ(dummy_eventid + FM_CHILD_BROKEN_EID_OFFSET, context_CFE_EVS_SendEvent[0].EventID);
UtAssert_INT32_EQ(CFE_EVS_EventType_ERROR, context_CFE_EVS_SendEvent[0].EventType);
Expand All @@ -758,11 +750,9 @@ void Test_FM_VerifyChildTask_ChildWriteIndexEqualChildQDepth(void)
bool result_verifychildtask = FM_VerifyChildTask(dummy_eventid, dummy_textptr);

uint8 count_sendevent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));
uint8 count_pspmemset = UT_GetStubCount(UT_KEY(CFE_PSP_MemSet));

// Assert
UtAssert_INT32_EQ(result_verifychildtask, false);
UtAssert_INT32_EQ(count_pspmemset, 0);
UtAssert_INT32_EQ(count_sendevent, 1);
UtAssert_INT32_EQ(dummy_eventid + FM_CHILD_BROKEN_EID_OFFSET, context_CFE_EVS_SendEvent[0].EventID);
UtAssert_INT32_EQ(CFE_EVS_EventType_ERROR, context_CFE_EVS_SendEvent[0].EventType);
Expand All @@ -781,11 +771,9 @@ void Test_FM_VerifyChildTask_Default(void)
bool result_verifychildtask = FM_VerifyChildTask(dummy_eventid, dummy_textptr);

uint8 count_sendevent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));
uint8 count_pspmemset = UT_GetStubCount(UT_KEY(CFE_PSP_MemSet));

// Assert
UtAssert_INT32_EQ(result_verifychildtask, true);
UtAssert_INT32_EQ(count_pspmemset, 1);
UtAssert_INT32_EQ(count_sendevent, 0);
}

Expand Down
4 changes: 2 additions & 2 deletions unit-test/fm_tbl_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ void Test_FM_ValidateTable_NameTooLong(void)
snprintf(DummyTable.FileSys[i].Name, OS_MAX_PATH_LEN, "Test");
}

memset(DummyTable.FileSys[0].Name, 'A', OS_MAX_PATH_LEN);
memset(DummyTable.FileSys[1].Name, 'A', OS_MAX_PATH_LEN);
memset(DummyTable.FileSys[0].Name, 'A', sizeof(DummyTable.FileSys[0].Name));
memset(DummyTable.FileSys[1].Name, 'A', sizeof(DummyTable.FileSys[1].Name));

int32 strCmpResult;
char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];
Expand Down
2 changes: 1 addition & 1 deletion unit-test/utilities/fm_test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void FM_Test_Setup(void)

UT_ResetState(0);

memset(&FM_GlobalData, 0, sizeof(FM_GlobalData_t));
memset(&FM_GlobalData, 0, sizeof(FM_GlobalData));
memset(context_CFE_EVS_SendEvent, 0, sizeof(context_CFE_EVS_SendEvent));
memset(&UT_CmdBuf, 0, sizeof(UT_CmdBuf));

Expand Down

0 comments on commit 1c1c1ad

Please sign in to comment.