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

Combine mostly duplicated logic in CFE_SB_BroadcastBufferToRoute #1460

Closed
skliper opened this issue Apr 29, 2021 · 3 comments · Fixed by #2151 or #2161
Closed

Combine mostly duplicated logic in CFE_SB_BroadcastBufferToRoute #1460

skliper opened this issue Apr 29, 2021 · 3 comments · Fixed by #2151 or #2161

Comments

@skliper
Copy link
Contributor

skliper commented Apr 29, 2021

Is your feature request related to a problem? Please describe.
Duplicated logic:

else if (Status == OS_QUEUE_FULL)
{
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId;
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_FULL_ERR_EID;
SBSndErr.EvtsToSnd++;
CFE_SB_Global.HKTlmMsg.Payload.PipeOverflowErrorCounter++;
PipeDscPtr->SendErrors++;
}
else
{
/* Unexpected error while writing to queue. */
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId;
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_WR_ERR_EID;
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].ErrStat = Status;
SBSndErr.EvtsToSnd++;
CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter++;
PipeDscPtr->SendErrors++;
} /*end if */

Describe the solution you'd like
Factor out, make an else with shared logic and internal if for the unique logic

Describe alternatives you've considered
None

Additional context
Code review

Requester Info
Jacob Hageman - NASA/GSFC

@thnkslprpt
Copy link
Contributor

You're thinking something like this Jake (@skliper)?

else
{
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId;
if (OsStatus == OS_QUEUE_FULL)
{
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_FULL_ERR_EID;
CFE_SB_Global.HKTlmMsg.Payload.PipeOverflowErrorCounter++;
}
else
{
/* Unexpected error while writing to queue. */
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_WR_ERR_EID;
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].OsStatus = OsStatus;
CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter++;
}
SBSndErr.EvtsToSnd++;
PipeDscPtr->SendErrors++;
} /*end if */

@skliper
Copy link
Contributor Author

skliper commented Sep 26, 2022

@thnkslprpt - looks good!

@thnkslprpt
Copy link
Contributor

Cheers Jake.

dzbaker added a commit that referenced this issue Oct 3, 2022
Fix #1460, Duplicated Logic in CFE_SB_BroadcastBufferToRoute
@dzbaker dzbaker closed this as completed in 3d8829e Oct 3, 2022
@dmknutsen dmknutsen added this to the Draco milestone Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants