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 #1519, Refactor CFE_TBL_SearchCmdHndlrTbl to simplify and unmix variables #2332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thnkslprpt
Copy link
Contributor

Checklist

Describe the contribution

Testing performed
GitHub CI actions all passing successfully (incl. Build + Run, Coverage/Functional Tests etc.).
Local testing to confirm net coverage unchanged and test commands also fine.

Expected behavior changes
No change to behavior.
Function is cleaner/simpler which eases future maintenance.

System(s) tested on
Debian GNU/Linux 11 (bullseye)
Current main branch of cFS bundle.

Contributor Info
Avi Weiss @thnkslprpt

Comment on lines 177 to 204
for (TblIndx = 0; CFE_TBL_CmdHandlerTbl[TblIndx].MsgTypes != CFE_TBL_TERM_MSGTYPE; TblIndx++)
{
/* Point to next entry in Command Handler Table */
TblIndx++;

/* Check to see if we found a matching Message ID */
if (CFE_SB_MsgId_Equal(CFE_TBL_CmdHandlerTbl[TblIndx].MsgId, MessageID) &&
(CFE_TBL_CmdHandlerTbl[TblIndx].MsgTypes != CFE_TBL_TERM_MSGTYPE))
if (CFE_SB_MsgId_Equal(CFE_TBL_CmdHandlerTbl[TblIndx].MsgId, MessageID))
{
/* Flag any found message IDs so that if there is an error, */
/* we can determine if it was a bad message ID or bad command code */
FoundMsg = true;

/* If entry in the Command Handler Table is a command entry, */
/* then check for a matching command code */
if (CFE_TBL_CmdHandlerTbl[TblIndx].MsgTypes == CFE_TBL_CMD_MSGTYPE)
{
if (CFE_TBL_CmdHandlerTbl[TblIndx].CmdCode == CommandCode)
{
/* Found matching message ID and Command Code */
FoundMatch = true;
break;
}
}
else /* Message is not a command message with specific command code */
{
/* Automatically assume a match when legit */
/* Message ID is all that is required */
/* Automatically assume a match when legit Message ID is all that is required */
FoundMatch = true;
break;
}
}
} while ((!FoundMatch) && (CFE_TBL_CmdHandlerTbl[TblIndx].MsgTypes != CFE_TBL_TERM_MSGTYPE));
}

Check warning

Code scanning / CodeQL

Unbounded loop Warning

This loop does not have a fixed bound.
@thnkslprpt thnkslprpt force-pushed the fix-1519-refactor-SearchCmdHndlrTbl branch from 8466132 to d9b51fb Compare October 26, 2023 15:32
@thnkslprpt thnkslprpt force-pushed the fix-1519-refactor-SearchCmdHndlrTbl branch from d9b51fb to 29b15c8 Compare April 19, 2024 22:20
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.

Refactor CFE_TBL_SearchCmdHndlrTbl to unmix error codes with indexes and simplify loop
1 participant