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

Add typedef for OSAL status codes #1108

Open
jphickey opened this issue Jul 16, 2021 · 1 comment
Open

Add typedef for OSAL status codes #1108

jphickey opened this issue Jul 16, 2021 · 1 comment

Comments

@jphickey
Copy link
Contributor

Is your feature request related to a problem? Please describe.
In the recent versions of CFE, a typedef (CFE_Status_t) is added and used for the return type on any function that returns a CFE status code, while OSAL continues to use a bare int32 return type.

Although the type does need to be integer in nature (to maintain semantics of equality checks, etc), the typedef does still serve a useful purpose, in that it implies behavioral characteristics of the function i.e. that its return value should be checked against the set of defined status values for that module where certain values have defined meaning - as opposed to a generic number.

Describe the solution you'd like
OSAL should define an OS_Status_t (which can be a typedef to int32) and prototypes of functions returning a status value should be updated to OS_Status_t to more clearly indicate when the return value should be compared against the set of constants defined in osapi-error.h.

Describe alternatives you've considered
Leave as int32 (inconsistent with CFE).

Additional context
In particular, having a separate type and macros helps identify cases where improper or incomplete type conversions are done, for instance see nasa/cFE#1599

Requester Info
Joseph Hickey, Vantage Systems, Inc.

jphickey added a commit to jphickey/osal that referenced this issue Jul 20, 2021
Minimal change to add a typedef for OS_Status_t, a macro
for constants/literals, and an inline function to convert
to "long" for printing/logging.
jphickey added a commit to jphickey/osal that referenced this issue Jul 20, 2021
Minimal change to add a typedef for OS_Status_t, a macro
for constants/literals, and an inline function to convert
to "long" for printing/logging.
@astrogeco astrogeco added this to the cFS-Draco milestone Jul 21, 2021
astrogeco added a commit to astrogeco/osal that referenced this issue Nov 3, 2021
@skliper skliper removed this from the Draco milestone Mar 18, 2022
@skliper
Copy link
Contributor

skliper commented May 27, 2022

Note the typedef was added in #1112, I guess this issue is still open to actually use it everywhere. For example:

int32 OS_GetErrorName(int32 error_num, os_err_name_t *err_name);

jphickey added a commit to jphickey/osal that referenced this issue Aug 10, 2022
Move all functions, macros, types, and other definitions
related to resource IDs and generic resource management into
a separate module, like CFE MSG and SBR, etc.

Notably this allows a mission to elect "strict" implementations
of these objects, where every ID type is unique, and assigning
between them (or uint32) results in a compiler error.
jphickey added a commit to jphickey/osal that referenced this issue Aug 10, 2022
Remove code blocks that were commented out, not needed.
jphickey added a commit to jphickey/osal that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants