Skip to content

fix: check CFE_SB_Subscribe return values in TO_LAB_init#233

Open
stark256-spec wants to merge 1 commit into
nasa:devfrom
stark256-spec:fix/check-subscribe-return-value
Open

fix: check CFE_SB_Subscribe return values in TO_LAB_init#233
stark256-spec wants to merge 1 commit into
nasa:devfrom
stark256-spec:fix/check-subscribe-return-value

Conversation

@stark256-spec
Copy link
Copy Markdown

Summary

Both CFE_SB_Subscribe() calls in TO_LAB_init() silently discard their return status. A failure means the application will not receive commands (TO_LAB_CMD_MID) or housekeeping requests (TO_LAB_SEND_HK_MID), yet it continues initialising and reports success to CFE_ES — making the fault invisible at startup.

Fixes #229.

Changes

  • Capture the return value of each CFE_SB_Subscribe() call and assign it to status
  • Emit TO_LAB_SUBSCRIBE_ERR_EID on failure, matching the error-handling style used throughout the rest of TO_LAB_init()
  • Split into two separate if (status == CFE_SUCCESS) blocks so a failure in the first prevents the second from masking it

Before / After

// BEFORE — return values silently ignored
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);

// AFTER — captured and reported
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);

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#229
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignored return value in TO_LAB_init()

2 participants