Skip to content

Commit

Permalink
Merge pull request #70 from thnkslprpt/fix-69-simplify-CS_AttemptTabl…
Browse files Browse the repository at this point in the history
…eReshare

Fix #69, Simplify CS_AttemptTableReshare
  • Loading branch information
dzbaker authored Apr 13, 2023
2 parents ebd338c + 28224de commit f26691b
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions fsw/src/cs_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,36 +1004,28 @@ int32 CS_HandleRoutineTableUpdates(void)
int32 CS_AttemptTableReshare(CS_Res_Tables_Table_Entry_t *ResultsEntry, CFE_TBL_Handle_t *LocalTblHandle,
CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, int32 *ResultGetInfo)
{
int32 Result = CS_SUCCESS;
int32 ResultShare = 0;
int32 ResultGetAddress = 0;
int32 Result;

/* Maybe the table came back, try and reshare it */
ResultShare = CFE_TBL_Share(LocalTblHandle, ResultsEntry->Name);
Result = CFE_TBL_Share(LocalTblHandle, ResultsEntry->Name);

if (ResultShare == CFE_SUCCESS)
if (Result == CFE_SUCCESS)
{
ResultsEntry->TblHandle = *LocalTblHandle;

*ResultGetInfo = CFE_TBL_GetInfo(TblInfo, ResultsEntry->Name);

/* need to try to get the address again */
ResultGetAddress = CFE_TBL_GetAddress((void *)LocalAddress, *LocalTblHandle);
Result = ResultGetAddress;
Result = CFE_TBL_GetAddress((void *)LocalAddress, *LocalTblHandle);

/* if the table was never loaded, release the address to prevent the table from being
locked by CS, which would prevent the owner app from updating it*/
if (ResultGetAddress == CFE_TBL_ERR_NEVER_LOADED)
if (Result == CFE_TBL_ERR_NEVER_LOADED)
{
CFE_TBL_ReleaseAddress(*LocalTblHandle);
}
}

else /* table was not there on the new share */
{
Result = ResultShare;
}

return Result;
}

Expand Down

0 comments on commit f26691b

Please sign in to comment.