From e3ad9ec9a24d2fcb3465f24d79c2acbcc1da86d4 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Fri, 10 May 2024 14:54:53 +0000 Subject: [PATCH] Fix #2559, Improve CFE_SB_AllocateMessageBuffer error report --- modules/sb/fsw/src/cfe_sb_api.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/sb/fsw/src/cfe_sb_api.c b/modules/sb/fsw/src/cfe_sb_api.c index bc4280ece..df5b77463 100644 --- a/modules/sb/fsw/src/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -2004,21 +2004,27 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe CFE_SB_Buffer_t *CFE_SB_AllocateMessageBuffer(size_t MsgSize) { CFE_ES_AppId_t AppId; + char AppName[OS_MAX_API_NAME] = {""}; CFE_SB_BufferD_t *BufDscPtr; CFE_SB_Buffer_t * BufPtr; + CFE_Status_t Status; AppId = CFE_ES_APPID_UNDEFINED; BufDscPtr = NULL; BufPtr = NULL; + Status = CFE_ES_GetAppID(&AppId); + if (MsgSize > CFE_MISSION_SB_MAX_SB_MSG_SIZE) { - CFE_ES_WriteToSysLog("%s: ZeroCopyGetPtr-Failed, MsgSize is too large\n", __func__); + CFE_ES_GetAppName(AppName, AppId, sizeof(AppName)); + CFE_ES_WriteToSysLog("%s %s: Failed, requested size %ld larger than allowed %d\n", + AppName, __func__, MsgSize, CFE_MISSION_SB_MAX_SB_MSG_SIZE); return NULL; } /* get callers AppId */ - if (CFE_ES_GetAppID(&AppId) == CFE_SUCCESS) + if (Status == CFE_SUCCESS) { CFE_SB_LockSharedData(__func__, __LINE__);