Closed TravisWhitaker closed 8 years ago
Yes, this is a fantastic idea. Most of those exits I just threw in for debugging. I haven’t even begun the phase of making the SDK consumer friendly yet. Perhaps that’s about to change.
If you want to get started on that, go right ahead. You’re more familiar with it than I am by a long shot.
On Nov 22, 2015, at 5:50 PM, Travis Whitaker notifications@github.com wrote:
A few of the API functions (at least flipper_attach(), perhaps others) do not allow the caller to handle a failure condition on their own, sometimes going as far as calling exit(). This is generally unsafe, as the caller might wish to continue despite the failure or require arbitrary cleanup before process termination. Although one could simply instruct the caller to register any required cleanup with atexit() or on_exit(), this is inflexible compared to simply returning an error code.
I would recommend a libflipper-specific global errno, as this doesn't necessitate changing the types of the existing functions, all C programmers should be familiar with the errno mechanism, and it would be mechanical to write wrappers around the new errno-ified functions to provide an interface with behavior identical to the current behavior. This would also make it easier to write bindings to the C library; it is non-trivial to recover from a foreign function calling exit() unexpectedly on your runtime!
I'd be happy to get started on implementing this. Thoughts?
— Reply to this email directly or view it on GitHub https://github.com/georgemorgan/flipper/issues/7.
This is almost consistently implemented. We could consider closing this issue.
The error interface seems to be working.
A few of the API functions (at least flipper_attach(), perhaps others) do not allow the caller to handle a failure condition on their own, sometimes going as far as calling exit(). This is generally unsafe, as the caller might wish to continue despite the failure or require arbitrary cleanup before process termination. Although one could simply instruct the caller to register any required cleanup with atexit() or on_exit(), this is inflexible compared to simply returning an error code.
I would recommend a libflipper-specific global errno, as this doesn't necessitate changing the types of the existing functions, all C programmers should be familiar with the errno mechanism, and it would be mechanical to write wrappers around the new errno-ified functions to provide an interface with behavior identical to the current behavior. This would also make it easier to write bindings to the C library; it is non-trivial to recover from a foreign function calling exit() unexpectedly on your runtime!
I'd be happy to get started on implementing this. Thoughts?