-
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
Argument checks in internal functions (CFE_SB_TransmitMsgValidate, etc) #1198
Comments
To summarize - the original subject that brought up this issue was about
The questions are:
There is also a similar issue described in #1194 where a common helper routine is invoked from a context with known-good inputs, and so the error checking on the output is skipped. There are other places where the same function is invoked where the input is not known to be good - so the range check inside the function is intended for those cases. But it is called from multiple contexts - and the question there is whether the caller needs to check for error returns even though it is not possible for it to fail in the current context where the input is known to be good. |
To be honest I don't think we had different opinions on this (after discussion). As an internal function it can do validation as a "helper" to the APIs, but doesn't require validation on the parameters that are guaranteed valid by the calling function. I thought the open issue was more for setting outputs on errors - bf8f481. Really just 2. I see #1194 as a separate issue (even from 2.), can we ignore possible returns when using an API from an internal function. We'd never do this for a system call even if we know it should never error, or likely any API from outside the core... can we really ignore it for our APIs? Implementations change... |
CCB:2021-03-17:
|
Action forward for this issue - document internal checks. |
Is your feature request related to a problem? Please describe.
As discussed in #1197 we need to have some consensus on the proper level of argument checking for internal helper functions.
Sometimes internal functions have tests to validate their inputs (range check etc) on behalf of the caller, in the case where several public APIs need to repeat the same tests -- putting these in a helper can reduce repeated code and make all APIs consistent in their validation (a good thing).
But in other cases the helper is invoked from contexts where the inputs are never out of range or pointers can never be NULL. Testing for such inputs can be redundant.
Describe the solution you'd like
Need to confirm/reach consensus on whether functions like CFE_SB_TransmitMsgValidate() in CFE SB need to validate all their arguments. Probably should better document which args are tested and why - and if there are limitations on other args (e.g. certain args are assumed to be non-null).
Additional context
This just causes some confusion during review and probably some additional comments/documentation could help.
See thread here: #1197 (comment)
Requester Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: