fix: make the behaviour of methods which set hid_error more consistent #425
No reviewers
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi!425
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/global-error-consistency"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From reading through the code I found that the behaviour of
hid_error()was rather inconsistent at times.The windows implementation would only set the device error if it encountered an error, and would never clear the last error.
The linux hidraw implementation would sometimes clear it, but not always.
I suppose that it could be fine as it, as you know that there is a new error from the return code, so maybe none of this is necessary other than the docs fix
You are right, there is so much wrong about
hid_errorin general.Starting with the inconsistency in the documentation and implementation, ending up with real thread-safety issues (despite the documentation).
We've introduced a lot problems by trying to make an improvement.
We tried to make
hid_errormimic theerrnobehavior, on the thread-safety part, but that was practically impossible to do so for a few reasons:errno, which is anint- hid_error is a dynamically allocated string, which has to befreed by each thread, where the error has been happening, and that is not true forhidraw(the only backend that has global errors implementation);Let me finally start making it right.
Pull request closed