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

Promote the internal OS_ObjectIdToArrayIndex function to the public API #589

Closed
jphickey opened this issue Sep 2, 2020 · 0 comments · Fixed by #596
Closed

Promote the internal OS_ObjectIdToArrayIndex function to the public API #589

jphickey opened this issue Sep 2, 2020 · 0 comments · Fixed by #596

Comments

@jphickey
Copy link
Contributor

jphickey commented Sep 2, 2020

Is your feature request related to a problem? Please describe.
Currently OSAL only provides a public API for OS_ConvertToArrayIndex which operates indiscriminately on any object type. For instance, if passed a task ID, it returns a value in the range of [0..OS_MAX_TASKS) and if passed a queue ID it will return a value in the range of [0..OS_MAX_QUEUES) and so forth.

But code using this function is using it to index an array of a specific object type (e.g. tasks). So this creates an opportunity for error if passed the wrong object ID - the caller may get a successful conversion but still get an index that is beyond the range of their local table.

Describe the solution you'd like
The OS_ObjectIdToArrayIndex function is better because it first enforces that the passed-in ID actually refers to the intended object type. The public API is actually just a wrapper around this that defeats the type check. For some reason this got relegated to an internal API.

Describe alternatives you've considered
Keep as is, accept risk of getting an index outside the expected range if IDs get mixed.

Additional context
As the function already exists it should be just a matter of putting its prototype into the public API, and providing a UT stub for it (easy).

Requester Info
Joseph Hickey, Vantage Systems, Inc.

jphickey added a commit to jphickey/osal that referenced this issue Sep 9, 2020
Move this existing function into the public API, as it is
performs more verification than the OS_ConvertToArrayIndex
function.
yammajamma added a commit that referenced this issue Sep 10, 2020
Fix #589, promote OS_ObjectIdToArrayIndex to public API
@astrogeco astrogeco added this to the 6.0.0 milestone Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants