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

Fix #1428, Refactor error handling for EVS_GetApplicationInfo() #2212

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 46 additions & 141 deletions modules/evs/fsw/src/cfe_evs_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
/* Defines */
#define CFE_EVS_PANIC_DELAY 500 /**< \brief Task delay before PSP panic */

/*
** Local function prototypes.
*/
void CFE_EVS_SendEventForGetAppInfoError(int32 Status, const char *LocalName, uint16 CommandCode);

/* Function Definitions */

/*----------------------------------------------------------------
Expand Down Expand Up @@ -305,6 +310,37 @@
return CFE_SUCCESS;
}

/*----------------------------------------------------------------
*
* Internal helper routine only, not part of API.
*
* This function handles error returns from calls to
* EVS_GetApplicationInfo() and generates a customized error
* event from the calling function.
*
*-----------------------------------------------------------------*/
void CFE_EVS_SendEventForGetAppInfoError(int32 Status, const char *LocalName, uint16 CommandCode)

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
switch (Status)
{
case 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)CommandCode);
break;

case 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)CommandCode);
break;

default:
EVS_SendEvent(CFE_EVS_ERR_NOAPPIDFOUND_EID, CFE_EVS_EventType_ERROR,
"Unable to retrieve application ID for %s: CC = %lu", LocalName,
(long unsigned int)CommandCode);
}
}

/*----------------------------------------------------------------
*
* Application-scope internal function
Expand Down Expand Up @@ -449,22 +485,9 @@
Status = CFE_EVS_EVT_NOT_REGISTERED;
}
}
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_SET_FILTER_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_SET_FILTER_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_SET_FILTER_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_SET_FILTER_CC);
}

return Status;
Expand Down Expand Up @@ -688,22 +711,9 @@
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);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_ENABLE_APP_EVENT_TYPE_CC);
}

if (Status == CFE_SUCCESS)
Expand Down Expand Up @@ -750,22 +760,9 @@
EVS_DisableTypes(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_DISABLE_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_DISABLE_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_DISABLE_APP_EVENT_TYPE_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_DISABLE_APP_EVENT_TYPE_CC);
}

if (Status == CFE_SUCCESS)
Expand Down Expand Up @@ -804,22 +801,9 @@
EVS_SendEvent(CFE_EVS_ENAAPPEVT_EID, CFE_EVS_EventType_DEBUG,
"Enable App Events Command Received with AppName = %s", LocalName);
}
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_EVENTS_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_EVENTS_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_EVENTS_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_ENABLE_APP_EVENTS_CC);
}

return Status;
Expand Down Expand Up @@ -851,22 +835,9 @@
EVS_SendEvent(CFE_EVS_DISAPPEVT_EID, CFE_EVS_EventType_DEBUG,
"Disable App Events Command Received with AppName = %s", LocalName);
}
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_DISABLE_APP_EVENTS_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_DISABLE_APP_EVENTS_CC);
}
else
{
EVS_SendEvent(CFE_EVS_ERR_NOAPPIDFOUND_EID, CFE_EVS_EventType_ERROR,
"Disable App Events Command: Unable to retrieve application ID for %s: CC = %lu", LocalName,
(long unsigned int)CFE_EVS_DISABLE_APP_EVENTS_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_DISABLE_APP_EVENTS_CC);
}

return Status;
Expand Down Expand Up @@ -899,22 +870,9 @@
EVS_SendEvent(CFE_EVS_RSTEVTCNT_EID, CFE_EVS_EventType_DEBUG,
"Reset Event Counter Command Received with AppName = %s", LocalName);
}
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_RESET_APP_COUNTER_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_RESET_APP_COUNTER_CC);
}
else
{
EVS_SendEvent(CFE_EVS_ERR_NOAPPIDFOUND_EID, CFE_EVS_EventType_ERROR,
"Reset Event Counter Command: Unable to retrieve application ID for %s: CC = %lu", LocalName,
(long unsigned int)CFE_EVS_RESET_APP_COUNTER_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_RESET_APP_COUNTER_CC);
}

return Status;
Expand Down Expand Up @@ -961,22 +919,9 @@
Status = CFE_EVS_EVT_NOT_REGISTERED;
}
}
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_RESET_FILTER_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_RESET_FILTER_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_RESET_FILTER_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_RESET_FILTER_CC);
}

return Status;
Expand Down Expand Up @@ -1012,22 +957,9 @@
EVS_SendEvent(CFE_EVS_RSTALLFILTER_EID, CFE_EVS_EventType_DEBUG,
"Reset All Filters Command Received with AppName = %s", LocalName);
}
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_RESET_ALL_FILTERS_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_RESET_ALL_FILTERS_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_RESET_ALL_FILTERS_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_RESET_ALL_FILTERS_CC);
}

return Status;
Expand Down Expand Up @@ -1093,23 +1025,9 @@
}
} /* end else*/
} /* end if (Status == CFE_SUCCESS) */

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_ADD_EVENT_FILTER_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_ADD_EVENT_FILTER_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_ADD_EVENT_FILTER_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_ADD_EVENT_FILTER_CC);
}

return Status;
Expand Down Expand Up @@ -1158,22 +1076,9 @@
Status = CFE_EVS_EVT_NOT_REGISTERED;
}
}
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_DELETE_EVENT_FILTER_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_DELETE_EVENT_FILTER_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_DELETE_EVENT_FILTER_CC);
CFE_EVS_SendEventForGetAppInfoError(Status, LocalName, CFE_EVS_DELETE_EVENT_FILTER_CC);
}

return Status;
Expand Down
Loading