From 38d6515cdf281e0023dbcca031c58904104bf836 Mon Sep 17 00:00:00 2001 From: Oliver Hamburger <55418244+oliverhamburger@users.noreply.github.com> Date: Tue, 20 Jul 2021 19:13:09 -0400 Subject: [PATCH] Fix #1667, CFE_SB_MsgHdrSize returns size_t (#1674) * Fix #1667, CFE_SB_MsgHdrSize returns size_t but still attempts to return CFE status code --- modules/core_api/fsw/inc/cfe_sb.h | 1 + modules/sb/fsw/src/cfe_sb_priv.h | 3 ++- modules/sb/fsw/src/cfe_sb_util.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/core_api/fsw/inc/cfe_sb.h b/modules/core_api/fsw/inc/cfe_sb.h index 0a04d7a18..92f83c82c 100644 --- a/modules/core_api/fsw/inc/cfe_sb.h +++ b/modules/core_api/fsw/inc/cfe_sb.h @@ -686,6 +686,7 @@ void *CFE_SB_GetUserData(CFE_MSG_Message_t *MsgPtr); ** This must point to the first byte of the message header. ** ** \return The size (in bytes) of the user data in the software bus message. +** \retval 0 if an error occurs, such as if the MsgPtr argument is not valid. **/ size_t CFE_SB_GetUserDataLength(const CFE_MSG_Message_t *MsgPtr); diff --git a/modules/sb/fsw/src/cfe_sb_priv.h b/modules/sb/fsw/src/cfe_sb_priv.h index 667e9d113..876de9e6b 100644 --- a/modules/sb/fsw/src/cfe_sb_priv.h +++ b/modules/sb/fsw/src/cfe_sb_priv.h @@ -757,7 +757,8 @@ CFE_SB_DestinationD_t *CFE_SB_GetDestPtr(CFE_SBR_RouteId_t RouteId, CFE_SB_PipeI ** if SB messages are implemented as CCSDS packets, the size of the header ** is different for command vs. telemetry packets. ** -** \returns Estimated number of bytes in the message header for the given message +** \returns Estimated number of bytes in the message header for the given message. +** \retval 0 if an error occurs, such as if the MsgPtr argument is not valid or header type cannot be identified. **/ size_t CFE_SB_MsgHdrSize(const CFE_MSG_Message_t *MsgPtr); diff --git a/modules/sb/fsw/src/cfe_sb_util.c b/modules/sb/fsw/src/cfe_sb_util.c index 0ea966c61..1a46605c1 100644 --- a/modules/sb/fsw/src/cfe_sb_util.c +++ b/modules/sb/fsw/src/cfe_sb_util.c @@ -53,7 +53,7 @@ size_t CFE_SB_MsgHdrSize(const CFE_MSG_Message_t *MsgPtr) if (MsgPtr == NULL) { - return CFE_SB_BAD_ARGUMENT; + return size; } CFE_MSG_GetHasSecondaryHeader(MsgPtr, &hassechdr); @@ -117,7 +117,7 @@ size_t CFE_SB_GetUserDataLength(const CFE_MSG_Message_t *MsgPtr) if (MsgPtr == NULL) { - return CFE_SB_BAD_ARGUMENT; + return TotalMsgSize; } CFE_MSG_GetSize(MsgPtr, &TotalMsgSize);