From ad743931bf676b1195082c11b6168fde14cf85d3 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 7 Jan 2021 12:44:58 -0500 Subject: [PATCH] Fix #1074, Refactor CFE_TIME_RegisterSynchCallback - One return point - Eliminates "possible uninitialized variable" static analysis warning --- fsw/cfe-core/src/time/cfe_time_api.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/fsw/cfe-core/src/time/cfe_time_api.c b/fsw/cfe-core/src/time/cfe_time_api.c index 37e8060d7..bfc97d60f 100644 --- a/fsw/cfe-core/src/time/cfe_time_api.c +++ b/fsw/cfe-core/src/time/cfe_time_api.c @@ -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;