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

Unnecessary duplicate 'if (status == CFE_SUCCESS)' check #2238

Closed
2 tasks done
thnkslprpt opened this issue Jan 23, 2023 · 1 comment
Closed
2 tasks done

Unnecessary duplicate 'if (status == CFE_SUCCESS)' check #2238

thnkslprpt opened this issue Jan 23, 2023 · 1 comment
Milestone

Comments

@thnkslprpt
Copy link
Contributor

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
CFE_EVS_EnableAppEventTypeCmd() and CFE_EVS_DisableAppEventTypeCmd() have a redundant repeat check of if (Status == CFE_SUCCESS).
Can be refactored to combine them, without any change to the underlying logic.

Expected behavior
Refactor to remove (unnecessary) duplicate if block.

Code snips

if (Status == CFE_SUCCESS)
{
/* Need to check for an out of range bitmask, since our bit masks are only 4 bits */
if (CmdPtr->BitMask == 0x0 || CmdPtr->BitMask > 0x0F)
{
EVS_SendEvent(CFE_EVS_ERR_INVALID_BITMASK_EID, CFE_EVS_EventType_ERROR,
"Bit Mask = 0x%08x out of range: CC = %lu", (unsigned int)CmdPtr->BitMask,
(long unsigned int)CFE_EVS_ENABLE_APP_EVENT_TYPE_CC);
Status = CFE_EVS_INVALID_PARAMETER;
}
else
{
EVS_EnableTypes(AppDataPtr, CmdPtr->BitMask);
}
}
else if (Status == CFE_EVS_APP_NOT_REGISTERED)
{
EVS_SendEvent(CFE_EVS_ERR_APPNOREGS_EID, CFE_EVS_EventType_ERROR, "%s not registered with EVS: CC = %lu",
LocalName, (long unsigned int)CFE_EVS_ENABLE_APP_EVENT_TYPE_CC);
}
else if (Status == CFE_EVS_APP_ILLEGAL_APP_ID)
{
EVS_SendEvent(CFE_EVS_ERR_ILLAPPIDRANGE_EID, CFE_EVS_EventType_ERROR,
"Illegal application ID retrieved for %s: CC = %lu", LocalName,
(long unsigned int)CFE_EVS_ENABLE_APP_EVENT_TYPE_CC);
}
else
{
EVS_SendEvent(CFE_EVS_ERR_NOAPPIDFOUND_EID, CFE_EVS_EventType_ERROR,
"Unable to retrieve application ID for %s: CC = %lu", LocalName,
(long unsigned int)CFE_EVS_ENABLE_APP_EVENT_TYPE_CC);
}
if (Status == CFE_SUCCESS)
{
EVS_SendEvent(CFE_EVS_ENAAPPEVTTYPE_EID, CFE_EVS_EventType_DEBUG,
"Enable App Event Type Command Received with AppName = %s, EventType Bit Mask = 0x%02x",
LocalName, CmdPtr->BitMask);
}

Identical case for CFE_EVS_DisableAppEventTypeCmd().

Reporter Info
Avi Weiss @thnkslprpt

@thnkslprpt thnkslprpt changed the title Combine unnecessary duplicate 'if (status == CFE_SUCCESS)' check Unnecessary duplicate 'if (status == CFE_SUCCESS)' check Jan 23, 2023
thnkslprpt added a commit to thnkslprpt/cFE that referenced this issue Jan 23, 2023
@thnkslprpt
Copy link
Contributor Author

Closing as first case was already raised in #1450
Will combine both cases into that Issue/PR.

@thnkslprpt thnkslprpt closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2023
@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
Development

Successfully merging a pull request may close this issue.

2 participants