Skip to content

Commit

Permalink
Fix nasa#1362, Simplify CFE_ES_QueryAllCmd file open logic
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed May 26, 2021
1 parent 8443a46 commit 491930b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
12 changes: 1 addition & 11 deletions modules/es/fsw/src/cfe_es_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,17 +1317,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data)
if (Result == CFE_SUCCESS)
{
/*
** Check to see if the file already exists
*/
Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY);
if (Result >= 0)
{
OS_close(FileDescriptor);
OS_remove(QueryAllFilename);
}

/*
** Create ES task log data file
** Create (or truncate) ES task log data file
*/
Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE,
OS_WRITE_ONLY);
Expand Down
6 changes: 3 additions & 3 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -3137,10 +3137,10 @@ void TestTask(void)
/* Test write of all app data to file with a file open failure */
ES_ResetUnitTest();
memset(&CmdBuf, 0, sizeof(CmdBuf));
UT_SetDeferredRetcode(UT_KEY(OS_OpenCreate), 1, OS_ERROR);
UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR);
UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.QueryAllCmd), UT_TPID_CFE_ES_CMD_QUERY_ALL_CC);
UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_ALL_APPS_EID), "CFE_ES_QueryAllCmd",
"Write application information file fail; file open");
UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_OSCREATE_ERR_EID), "CFE_ES_QueryAllCmd",
"Write application information file fail; OS_OpenCreate failure");

/* Test sending a write request for all tasks with an
* invalid command length
Expand Down

0 comments on commit 491930b

Please sign in to comment.