Conversation
|
When a client code gets an "error string" as printf("Last HIDAPI call status: %S", hide_error());and that would immediately lead to crash, since I'd suggest always return a valid c-string (non-NULL) instead. |
|
my suggestion stands @z3ntu if you accept - please update PR accordingly, otherwise give your note why you wouldn't do it within this PR; maybe we'll have a separate task for it |
|
Yes, will update it. I've just been travelling a lot in the past couple of days and spending time on other projects inbetween. Do you think it's better that if the |
to be honest I'm more concerned of usage on the user side, and I'll support any reasonable good implementation, so it is up to you to decide |
|
The last sounds the best imo |
9683cba to
06a534f
Compare
|
Should be good for a review now |
Youw
left a comment
There was a problem hiding this comment.
Looks like documentation has to be updated(
|
|
||
| Whether a function sets the last error is noted in its | ||
| documentation. These functions will reset the last error | ||
| to NULL before their execution. |
There was a problem hiding this comment.
Thanks to comment from @canselcik, we see, that the part about NULL isn't true.
|
|
||
| Strings returned from hid_error() must not be freed by the user! | ||
|
|
||
| This function is thread-safe, and error messages are thread-local. |
There was a problem hiding this comment.
And it is not thread-safe, when you're using same device from different threads.
Here is my first try at implementing error messages for the Linux/hidraw implementation.
NULLintohid_erroras I suggested in libusb: allow hidapi to be configured without using iconv #123.A few extra questions:
utf8_to_wchar_tthe input is calledutf8. As far as I know, the encoding used inmbstowcsdepends on the current locale, if if I haven't set my locale to use UTF8, then the input is not UTF8.register_errorequivalent inwindows/hid.cdoesn't use its argumentconst char *op. Is that intended?HidD_GetPreparsedDataactually set the error code forGetLastError()?Originally signal11/hidapi#125