-
Notifications
You must be signed in to change notification settings - Fork 202
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
thnkslprpt
wants to merge
1
commit into
nasa:main
Choose a base branch
from
thnkslprpt:fix-1519-refactor-SearchCmdHndlrTbl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix #1519, Refactor CFE_TBL_SearchCmdHndlrTbl
to simplify and unmix variables
#2332
thnkslprpt
wants to merge
1
commit into
nasa:main
from
thnkslprpt:fix-1519-refactor-SearchCmdHndlrTbl
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
force-pushed
the
fix-1519-refactor-SearchCmdHndlrTbl
branch
from
October 26, 2023 15:32
8466132
to
d9b51fb
Compare
…nmix variables
thnkslprpt
force-pushed
the
fix-1519-refactor-SearchCmdHndlrTbl
branch
from
April 19, 2024 22:20
d9b51fb
to
29b15c8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Describe the contribution
CFE_TBL_SearchCmdHndlrTbl
to unmix error codes with indexes and simplify loop #1519index
/return
during the loop (must mix at the end of the function to avoid multiple returns)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