From 5063822b13f03782baebfadcfd05be73161ed5c4 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 17 Mar 2021 17:13:28 -0400 Subject: [PATCH] Fix #1185, Squash possible uninitialized variable false alarms --- modules/es/fsw/src/cfe_es_apps.c | 2 +- modules/sb/fsw/src/cfe_sb_api.c | 2 +- modules/time/fsw/src/cfe_time_api.c | 27 +++++++++++++-------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/modules/es/fsw/src/cfe_es_apps.c b/modules/es/fsw/src/cfe_es_apps.c index 1944e7153..4b7348a4c 100644 --- a/modules/es/fsw/src/cfe_es_apps.c +++ b/modules/es/fsw/src/cfe_es_apps.c @@ -660,7 +660,7 @@ int32 CFE_ES_AppCreate(CFE_ES_AppId_t *ApplicationIdPtr, const char *AppName, co { CFE_Status_t Status; CFE_ES_AppRecord_t *AppRecPtr; - CFE_ResourceId_t PendingResourceId; + CFE_ResourceId_t PendingResourceId = CFE_RESOURCEID_UNDEFINED; /* * The AppName must not be NULL diff --git a/modules/sb/fsw/src/cfe_sb_api.c b/modules/sb/fsw/src/cfe_sb_api.c index f96ba031d..33f59ff15 100644 --- a/modules/sb/fsw/src/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -95,7 +95,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *Pi osal_id_t SysQueueId; int32 Status; CFE_SB_PipeD_t * PipeDscPtr; - CFE_ResourceId_t PendingPipeId; + CFE_ResourceId_t PendingPipeId = CFE_RESOURCEID_UNDEFINED; uint16 PendingEventId; char FullName[(OS_MAX_API_NAME * 2)]; diff --git a/modules/time/fsw/src/cfe_time_api.c b/modules/time/fsw/src/cfe_time_api.c index e1ad20845..3176e08ca 100644 --- a/modules/time/fsw/src/cfe_time_api.c +++ b/modules/time/fsw/src/cfe_time_api.c @@ -736,21 +736,20 @@ int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncP 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_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])) || - CFE_TIME_Global.SynchCallback[AppIndex].Ptr != CallbackFuncPtr) - { - Status = CFE_TIME_CALLBACK_NOT_REGISTERED; - } - else - { - CFE_TIME_Global.SynchCallback[AppIndex].Ptr = NULL; + if (Status == CFE_SUCCESS) + { + + if (AppIndex >= (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])) || + CFE_TIME_Global.SynchCallback[AppIndex].Ptr != CallbackFuncPtr) + { + Status = CFE_TIME_CALLBACK_NOT_REGISTERED; + } + else + { + CFE_TIME_Global.SynchCallback[AppIndex].Ptr = NULL; + } + } } return Status;