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

Module list count includes both CFE_PSP_BASE_MODULE_LIST and the configurable PspModuleList but some APIs use just the latter. #319

Closed
skliper opened this issue Dec 9, 2021 · 2 comments · Fixed by #354
Labels
bug Something isn't working

Comments

@skliper
Copy link
Contributor

skliper commented Dec 9, 2021

Describe the bug
Both lists are initilized:

void CFE_PSP_ModuleInit(void)
{
/* First initialize the fixed set of modules for this PSP */
CFE_PSP_ModuleInitList(CFE_PSP_BASE_MODULE_LIST);
/* Then initialize any user-selected extension modules */
CFE_PSP_ModuleInitList(GLOBAL_CONFIGDATA.PspModuleList);
}

which increments the CFE_PSP_ModuleCount:

++CFE_PSP_ModuleCount;

but then the API's use CFE_PSP_ModuleCount to limit references to just the configurable list (and other related issues):

int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId)
{
uint32 i;
int32 Result;
CFE_StaticModuleLoadEntry_t *Entry;
Entry = GLOBAL_CONFIGDATA.PspModuleList;
Result = CFE_PSP_INVALID_MODULE_NAME;
i = 0;
while (i < CFE_PSP_ModuleCount)
{
if (strcmp(Entry->Name, ModuleName) == 0)
{
*PspModuleId = CFE_PSP_MODULE_BASE | (i & CFE_PSP_MODULE_INDEX_MASK);
Result = CFE_PSP_SUCCESS;
break;
}
++Entry;
++i;
}
return Result;
}

To Reproduce
For example if there's 1 entry in CFE_PSP_BASE_MODULE_LIST and 1 in the additional PspModuleList, then CFE_PSP_ModuleCount will == 2. Then if you call CFE_PSP_MODULE_FindByName with any module not in the PspModuleList it'll actually go off the end of the PspModuleList since it's limited to 2... and it won't find anything in the CFE_PSP_BASE_MODULE_LIST.

Expected behavior
A complete module list should be used for APIs that includes both the built in and added.

Code snips
See above.

System observed on:
N/A - code inspection

Additional context
Stakeholder identified issue

Reporter Info
Jacob Hageman - NASA/GSFC

@skliper skliper added the bug Something isn't working label Dec 9, 2021
@skliper
Copy link
Contributor Author

skliper commented Dec 9, 2021

Ping - @superolmo

@jphickey
Copy link
Contributor

Just saw this after I wrote up #353 (duplicate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants