nasa / osal

The Core Flight System (cFS) Operating System Abstraction Layer (OSAL)
Apache License 2.0
555 stars 217 forks source link

Return OS_ERROR if `OS_ObjectIdGetById` fails in vxworks `OS_ShellOutputToFile_Impl` #1102

Open skliper opened 3 years ago

skliper commented 3 years ago

Is your feature request related to a problem? Please describe. Coverage test highlights somewhat unexpected behavior in the VxWorks OS_ShellOutputToFile_impl where it will still return success if OS_ObjectIdGetById doesn't return OS_SUCCESS. There isn't a real case where OS_ObjectIdGetById would fail that I know of, but the logic is a bit strange. https://github.com/nasa/osal/blob/cb95655f1743890835a10847439380b5ef7e31a0/src/os/vxworks/src/os-impl-shell.c#L79-L102

Describe the solution you'd like Return OS_ERROR if there is an error.

Describe alternatives you've considered None

Additional context None

Requester Info Jacob Hageman - NASA/GSFC

jphickey commented 3 years ago

Actually I think the issue/error lies here:

https://github.com/nasa/osal/blob/cb95655f1743890835a10847439380b5ef7e31a0/src/os/vxworks/src/os-impl-shell.c#L71-L72

It should be using ReturnCode instead of Result to hold the value. The former is the OSAL status code, the latter is the VxWorks status code. It's just coincidence that OK and OS_SUCCESS are the same value (0) so it works and this mismatch was not noticed.