Hotplug: device->next must be NULL in callback #791
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#791
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Tracking from #790 / #674.
Contract (documented in #790)
Current state
Backends invoke the user callback with a
hid_device_info*whosenextfield still points into the backend-internal enumeration list. Example: libusb/hid.c:1123 already carries a `TODO` for this:```c
/* TODO: possibly make the `next` field NULL to match the behavior on other systems */
```
The other backends are similarly inconsistent.
Proposed fix
Before dispatching the callback, copy the `hid_device_info` into a local struct on the dispatcher's stack with `.next = NULL`, then pass a pointer to that local struct into the callback. Do not deep-copy the string fields — they are still owned by HIDAPI and remain valid for the duration of the callback.
This avoids exposing the internal list layout to user code and gives one consistent cross-backend contract.
Backends to touch
Related