-
Notifications
You must be signed in to change notification settings - Fork 206
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 #1517, Reformat do/while loop to while (style change only) #2180
Closed
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
+489
to
+503
while ((RegIndx == CFE_TBL_NOT_FOUND) && (i < (CFE_PLATFORM_TBL_MAX_NUM_TABLES - 1))) | ||
{ | ||
/* Point to next record in the Table Registry */ | ||
i++; | ||
|
||
/* Check to see if the record is currently being used */ | ||
if (!CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED)) | ||
/* Check to see if the record is currently being used and perform a case-sensitive name comparison */ | ||
if (!CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED) && | ||
strcmp(TblName, CFE_TBL_Global.Registry[i].Name) == 0) | ||
{ | ||
/* Perform a case sensitive name comparison */ | ||
if (strcmp(TblName, CFE_TBL_Global.Registry[i].Name) == 0) | ||
{ | ||
/* If the names match, then return the index */ | ||
RegIndx = i; | ||
} | ||
/* If the names match, then return the index */ | ||
RegIndx = i; | ||
} | ||
} while ((RegIndx == CFE_TBL_NOT_FOUND) && (i < (CFE_PLATFORM_TBL_MAX_NUM_TABLES - 1))); | ||
else | ||
{ | ||
/* Point to next record in the Table Registry */ | ||
i++; | ||
} | ||
} |
Check warning
Code scanning / CodeQL-coding-standard
Unbounded loop
The loop counter i is not always incremented in the loop body.
thnkslprpt
force-pushed
the
fix-1517-reformat-do-while-loop
branch
from
March 14, 2023 11:37
e9f2a78
to
0b00937
Compare
I think the intent here is that if its a common routine, a helper function would be better, rather than repeating the code (the latter is probably how they ended up diverging in the first place) |
No longer relevent since #2539 |
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_FindTableInRegistry
andCFE_TBL_FindFreeRegistryEntry
#1517do...while
loop inCFE_TBL_FindTableInRegistry()
into awhile
loop, which is the same structure used in the neighboring functions.Testing performed
GitHub CI actions (incl. Build + Run, Unit Tests etc.) all passing successfully.
Expected behavior changes
No impact on behavior - code logic essentially unchanged.
Contributor Info
Avi Weiss @thnkslprpt