-
Notifications
You must be signed in to change notification settings - Fork 219
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
Deprecate OS_open and OS_creat #556
Comments
One other possible compromise is to keep these as-is returning This has been a source of confusion in the past, see #498. |
Would like to get some feedback on this idea in the next CCB. |
I'm in favor of the suggested approach (deprecate, expose OS_OpenCreate). |
@acudmore @ejtimmon ping, deprecation proposal |
CCB 2020-08-12: No objections, but solicited responses/review. |
Also @CDKnightNASA - you might have some thoughts here as well? Summary of questions are:
If (1) is yes, then:
If (1) is no, then:
|
No objections to just using OS_OpenCreate as this follows the normal API structure found in many file systems where the create option flag is passed in. Hopefully the change only impacts a limited number of applications. |
Worth noting, in case anyone is unconvinced about the benefits of being type-strict, I found a mistake/bug in the unit tests here, that's probably been lurking for quite some time, where it fails to handle this return code properly: osal/src/tests/file-api-test/file-api-test.c Lines 794 to 795 in 8cfd6fe
This type of goof-up becomes very apparent/obvious when using a distinct type, and can actually trigger a compiler error if desired. |
This will impact several apps, but I'm not opposed. |
@jphickey - did you start implementing this change, or want me to take it? |
A previously merged PR has already exposed the I hadn't started on that apart yet because I needed to get nasa/cFE#868 in first, but now that is settled there shouldn't be any issue in replacing these refs now. I can submit a CFE ticket for that. If someone else is available and wants to take it on that would be fine, otherwise I'm happy to do it. |
See nasa/cFE#893 for the CFE work to be done. |
These functions are replaced by OS_OpenCreate, which implements both functions via flags, and follows the correct OSAL API patterns.
Fix #556, Deprecate OS_open and OS_creat
Is your feature request related to a problem? Please describe.
For historical/backward compatibility reasons, the API of these two functions doesn't follow the typical flow. Rather than providing a
uint32
ID output buffer as the first argument with a separate int32 return code, they return the OSAL ID cast as anint32
on success. For these functions, the caller is expected to check if the result is negative, and if so, consider it an error code. Whereas if it is non-negative, the caller is expected to cast it back to auint32
type and interpret it as an OSAL ID.Describe the solution you'd like
These should be like all other OSAL APIs and pass back the ID separately from the return/error status.
Describe alternatives you've considered
Leave as is. But these two functions present a challenge when making a distinct type for OSAL IDs .
Additional context
In the current implementation,. these are just compatibility wrappers anyway. They both call
OS_OpenCreate()
internally, which provides both open (existing file) and creat (new file) based on the flags it was passed. TheOS_OpenCreate
function does follow the correct pattern so one option would be to just expose this to the public API.The other option is to create a new version of OS_open and OS_creat which follow the correct pattern. But in order to provide a transition they would have to use different names.
Requester Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: