Skip to content

Promote the internal OS_ObjectIdToArrayIndex function to the public API #589

@jphickey

Description

@jphickey

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions