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

Too strict of check before calling "Init" function of module #303

Closed
jphickey opened this issue Sep 3, 2021 · 1 comment · Fixed by #304 or #307
Closed

Too strict of check before calling "Init" function of module #303

jphickey opened this issue Sep 3, 2021 · 1 comment · Fixed by #304 or #307
Assignees
Labels
bug Something isn't working

Comments

@jphickey
Copy link
Contributor

jphickey commented Sep 3, 2021

Describe the bug
For PSP modules the initialization is only called if the module type is "SIMPLE" - but this is not necessary to enforce, because the intent is to allow this to be extended to other module types as the mission requires.

Since the "Init" function pointer is a fixed/defined entry (so all modules have it, regardless of type) and it is already permitted to be NULL if it is not needed, then there is no real reason to restrict calling it to the "SIMPLE" module type.

To Reproduce
Define an extension module type and try to use it with Caelum. It will not be initialized as expected, the init call is skipped.

Expected behavior
If a module provides an init function, it should be called, regardless of whether the module type is "SIMPLE" or something else.

Code snips
Check is here:

if ((uint32)ApiPtr->ModuleType == CFE_PSP_MODULE_TYPE_SIMPLE && ApiPtr->Init != NULL)

Through some form of evolution it was checking specifically for CFE_PSP_MODULE_TYPE_SIMPLE only, but it would be better to check that ModuleType != CFE_PSP_MODULE_TYPE_INVALID instead.

System observed on:
Ubuntu

Additional context
Only breaks when trying to add modules of other types (extensions). Could theoretically be fixed in other ways, but still, the intent of this code is only to confirm that the module structure is initialized to something before invoking a function pointer. So it is more correct to check that it is not invalid, rather than checking specifically for one value.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this Sep 3, 2021
@jphickey jphickey added the bug Something isn't working label Sep 3, 2021
@jphickey
Copy link
Contributor Author

jphickey commented Sep 3, 2021

Calling this a bug because it didn't work for the use case as intended. Fix is simple enough though.

jphickey added a commit to jphickey/PSP that referenced this issue Sep 3, 2021
Rather than only calling "Init" on a "SIMPLE" module type, just
check that it is not invalid instead.  Even extension types
still have an Init routine that needs to be called.
jphickey added a commit to jphickey/PSP that referenced this issue Sep 3, 2021
Rather than only calling "Init" on a "SIMPLE" module type, just
check that it is not invalid instead.  Even extension types
still have an Init routine that needs to be called.
astrogeco added a commit that referenced this issue Sep 7, 2021
Fix #303, check that module type is not invalid
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
1 participant