From 3428882045e09501ab049bfdbe5b504ef79d28f6 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Fri, 28 Jan 2022 18:00:55 -0700 Subject: [PATCH] Fix #2040, Improve CFE_SB_IsValidMsgId handler If no return value override is set test against CFE_SB_INVALID_MSG_ID --- modules/core_api/ut-stubs/src/cfe_sb_handlers.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/core_api/ut-stubs/src/cfe_sb_handlers.c b/modules/core_api/ut-stubs/src/cfe_sb_handlers.c index 2e245748e..a24f26750 100644 --- a/modules/core_api/ut-stubs/src/cfe_sb_handlers.c +++ b/modules/core_api/ut-stubs/src/cfe_sb_handlers.c @@ -400,10 +400,17 @@ void UT_DefaultHandler_CFE_SB_IsValidMsgId(void *UserObj, UT_EntryKey_t FuncKey, { int32 status; bool return_value; + CFE_SB_MsgId_t MsgId = UT_Hook_GetArgValueByName(Context, "MsgId", CFE_SB_MsgId_t); - UT_Stub_GetInt32StatusCode(Context, &status); - - return_value = status; + if (UT_Stub_GetInt32StatusCode(Context, &status)) + { + return_value = status; + } + else + { + /* The only invalid value UT's should be using is CFE_SB_INVALID_MSG_ID */ + return_value = !CFE_SB_MsgId_Equal(MsgId, CFE_SB_INVALID_MSG_ID); + } UT_Stub_SetReturnValue(FuncKey, return_value); }