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 #823, avoid infinite loop in CDS registry find #857

Merged
Merged
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
15 changes: 8 additions & 7 deletions fsw/cfe-core/src/es/cfe_es_cds.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,10 @@ int32 CFE_ES_UnlockCDSRegistry(void)
int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
{
int32 RegIndx = CFE_ES_CDS_NOT_FOUND;
int32 i = -1;
uint32 i = 0;

do
while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < CFE_ES_Global.CDSVars.MaxNumRegEntries) )
{
/* Point to next record in the CDS Registry */
i++;

/* Check to see if the record is currently being used */
if (CFE_ES_Global.CDSVars.Registry[i].Taken == true)
{
Expand All @@ -654,7 +651,11 @@ int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
RegIndx = i;
}
}
} while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < (CFE_ES_Global.CDSVars.MaxNumRegEntries-1)) );

/* Point to next record in the CDS Registry */
i++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to do a for loop with a break?


};

return RegIndx;
} /* End of CFE_ES_FindCDSInRegistry() */
Expand All @@ -670,7 +671,7 @@ int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
int32 CFE_ES_FindFreeCDSRegistryEntry(void)
{
int32 RegIndx = CFE_ES_CDS_NOT_FOUND;
int32 i = 0;
uint32 i = 0;

while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < CFE_ES_Global.CDSVars.MaxNumRegEntries) )
{
Expand Down