Skip to content

Commit

Permalink
Merge pull request nasa#1075 from skliper/fix1074-multiple_returns
Browse files Browse the repository at this point in the history
Fix nasa#1074, Refactor CFE_TIME_RegisterSynchCallback
  • Loading branch information
astrogeco authored Jan 25, 2021
2 parents a68947e + ad74393 commit c9f9d42
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions fsw/cfe-core/src/time/cfe_time_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,21 +697,20 @@ int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPt
if (Status == CFE_SUCCESS)
{
Status = CFE_ES_AppID_ToIndex(AppId, &AppIndex);
}
if (Status != CFE_SUCCESS)
{
/* Called from an invalid context */
return Status;
}

if (AppIndex >= (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])) ||
CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr != NULL)
{
Status = CFE_TIME_TOO_MANY_SYNCH_CALLBACKS;
}
else
{
CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr = CallbackFuncPtr;
if (Status == CFE_SUCCESS)
{

if (AppIndex >= (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])) ||
CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr != NULL)
{
Status = CFE_TIME_TOO_MANY_SYNCH_CALLBACKS;
}
else
{
CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr = CallbackFuncPtr;
}
}
}

return Status;
Expand Down

0 comments on commit c9f9d42

Please sign in to comment.