From 874f69968f36bb32d79fdbc43de811490944ae01 Mon Sep 17 00:00:00 2001 From: stark256-spec Date: Tue, 2 Jun 2026 14:34:44 -0500 Subject: [PATCH] fix: check CFE_SB_Subscribe return values in TO_LAB_init Both CFE_SB_Subscribe calls for TO_LAB_CMD_MID and TO_LAB_SEND_HK_MID were silently ignoring the return status. A failure here means the application will not receive commands or housekeeping requests, but would continue initialising and report success to CFE_ES. Capture the return value for each call and emit a TO_LAB_SUBSCRIBE_ERR_EID event on failure, matching the error-handling style used throughout the rest of TO_LAB_init(). Each Subscribe is now guarded by a separate 'if (status == CFE_SUCCESS)' block so a failure in the first prevents the second from masking it. Fixes: nasa/to_lab#229 --- fsw/src/to_lab_app.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/fsw/src/to_lab_app.c b/fsw/src/to_lab_app.c index c6857c3..b95ed74 100644 --- a/fsw/src/to_lab_app.c +++ b/fsw/src/to_lab_app.c @@ -208,9 +208,32 @@ CFE_Status_t TO_LAB_init(void) if (status == CFE_SUCCESS) { - CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_CMD_MID), TO_LAB_Global.Cmd_pipe); - CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_SEND_HK_MID), TO_LAB_Global.Cmd_pipe); + status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_CMD_MID), TO_LAB_Global.Cmd_pipe); + if (status != CFE_SUCCESS) + { + CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_ERR_EID, + CFE_EVS_EventType_ERROR, + "L%d TO Can't subscribe to Cmd MID, status %i", + __LINE__, + (int)status); + } + } + if (status == CFE_SUCCESS) + { + status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_SEND_HK_MID), TO_LAB_Global.Cmd_pipe); + if (status != CFE_SUCCESS) + { + CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_ERR_EID, + CFE_EVS_EventType_ERROR, + "L%d TO Can't subscribe to HK MID, status %i", + __LINE__, + (int)status); + } + } + + if (status == CFE_SUCCESS) + { /* Create TO TLM pipe */ status = CFE_SB_CreatePipe(&TO_LAB_Global.Tlm_pipe, ToTlmPipeDepth, ToTlmPipeName); if (status != CFE_SUCCESS)