Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move calls to GetPipeName() to reduce code duplication in BroadcastBufferToRoute() #2282

Open
2 tasks done
thnkslprpt opened this issue Apr 5, 2023 · 0 comments · May be fixed by #2283
Open
2 tasks done

Move calls to GetPipeName() to reduce code duplication in BroadcastBufferToRoute() #2282

thnkslprpt opened this issue Apr 5, 2023 · 0 comments · May be fixed by #2283

Comments

@thnkslprpt
Copy link
Contributor

thnkslprpt commented Apr 5, 2023

Checklist

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
These 3 calls to CFE_SB_GetPipeName() in CFE_SB_BroadcastBufferToRoute() could be reduced to 1 if it was moved up a bit higher to just after the opening of the for loop block.

Code snips

for (i = 0; i < SBSndErr.EvtsToSnd; i++)
{
if (SBSndErr.EvtBuf[i].EventId == CFE_SB_MSGID_LIM_ERR_EID)
{
/* Determine if event can be sent without causing recursive event problem */
if (CFE_SB_RequestToSendEvent(TskId, CFE_SB_MSGID_LIM_ERR_EID_BIT) == CFE_SB_GRANTED)
{
CFE_SB_GetPipeName(PipeName, sizeof(PipeName), SBSndErr.EvtBuf[i].PipeId);
CFE_ES_PerfLogEntry(CFE_MISSION_SB_MSG_LIM_PERF_ID);
CFE_ES_PerfLogExit(CFE_MISSION_SB_MSG_LIM_PERF_ID);
CFE_EVS_SendEventWithAppID(CFE_SB_MSGID_LIM_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Msg Limit Err,MsgId 0x%x,pipe %s,sender %s",
(unsigned int)CFE_SB_MsgIdToValue(BufDscPtr->MsgId), PipeName,
CFE_SB_GetAppTskName(TskId, FullName));
/* clear the bit so the task may send this event again */
CFE_SB_FinishSendEvent(TskId, CFE_SB_MSGID_LIM_ERR_EID_BIT);
}
}
else if (SBSndErr.EvtBuf[i].EventId == CFE_SB_Q_FULL_ERR_EID)
{
/* Determine if event can be sent without causing recursive event problem */
if (CFE_SB_RequestToSendEvent(TskId, CFE_SB_Q_FULL_ERR_EID_BIT) == CFE_SB_GRANTED)
{
CFE_SB_GetPipeName(PipeName, sizeof(PipeName), SBSndErr.EvtBuf[i].PipeId);
CFE_ES_PerfLogEntry(CFE_MISSION_SB_PIPE_OFLOW_PERF_ID);
CFE_ES_PerfLogExit(CFE_MISSION_SB_PIPE_OFLOW_PERF_ID);
CFE_EVS_SendEventWithAppID(CFE_SB_Q_FULL_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Pipe Overflow,MsgId 0x%x,pipe %s,sender %s",
(unsigned int)CFE_SB_MsgIdToValue(BufDscPtr->MsgId), PipeName,
CFE_SB_GetAppTskName(TskId, FullName));
/* clear the bit so the task may send this event again */
CFE_SB_FinishSendEvent(TskId, CFE_SB_Q_FULL_ERR_EID_BIT);
}
}
else
{
/* Determine if event can be sent without causing recursive event problem */
if (CFE_SB_RequestToSendEvent(TskId, CFE_SB_Q_WR_ERR_EID_BIT) == CFE_SB_GRANTED)
{
CFE_SB_GetPipeName(PipeName, sizeof(PipeName), SBSndErr.EvtBuf[i].PipeId);
CFE_EVS_SendEventWithAppID(CFE_SB_Q_WR_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Pipe Write Err,MsgId 0x%x,pipe %s,sender %s,stat %ld",
(unsigned int)CFE_SB_MsgIdToValue(BufDscPtr->MsgId), PipeName,
CFE_SB_GetAppTskName(TskId, FullName), (long)(SBSndErr.EvtBuf[i].OsStatus));
/* clear the bit so the task may send this event again */
CFE_SB_FinishSendEvent(TskId, CFE_SB_Q_WR_ERR_EID_BIT);
}
}
}

Expected behavior
Reduce unnecessary code duplication.

Reporter Info
Avi Weiss @thnkslprpt

@thnkslprpt thnkslprpt changed the title Move calls to GetPipeName() to reduce code duplication in BroadcastBufferToRoute() Move calls to GetPipeName() to reduce code duplication in BroadcastBufferToRoute() Apr 5, 2023
thnkslprpt added a commit to thnkslprpt/cFE that referenced this issue Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants