Skip to content

Commit

Permalink
Fix nasa#1074, Refactor CFE_TIME_RegisterSynchCallback
Browse files Browse the repository at this point in the history
- One return point
- Eliminates "possible uninitialized variable" static
analysis warning
  • Loading branch information
skliper committed Jan 7, 2021
1 parent 56397a3 commit ad74393
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 @@ -765,21 +765,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 ad74393

Please sign in to comment.