Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid multiple returns and possible uninitialized variable warning in CFE_TIME_RegisterSynchCallback #1074

Closed
skliper opened this issue Jan 7, 2021 · 0 comments · Fixed by #1075 or #1109

Comments

@skliper
Copy link
Contributor

skliper commented Jan 7, 2021

Is your feature request related to a problem? Please describe.
Multiple returns and an (invalid) possible uninitialized variable warning shows up from static analysis:

int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr)
{
int32 Status;
CFE_ES_ResourceID_t AppId;
uint32 AppIndex;
Status = CFE_ES_GetAppID(&AppId);
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;
}
return Status;
} /* End of CFE_TIME_RegisterSynchCallback() */

Describe the solution you'd like
Refactor for one return and avoid warning.

Describe alternatives you've considered
Leave as is (works)

Additional context
None

Requester Info
Jacob Hageman - NASA/GSFC

@skliper skliper added this to the 7.0.0 milestone Jan 7, 2021
skliper added a commit to skliper/cFE that referenced this issue Jan 7, 2021
- One return point
- Eliminates "possible uninitialized variable" static
analysis warning
astrogeco added a commit that referenced this issue Jan 25, 2021
Fix #1074, Refactor CFE_TIME_RegisterSynchCallback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants