| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Initialize active_config to an invalid value to avoid the following
compilation error:
os/linux_usbfs.c: In function ‘op_get_configuration’:
os/linux_usbfs.c:1452:12: error: ‘active_config’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
1452 | *config = (uint8_t)active_config;
Closes #1062
Closes #1063
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
libusb unconditionally uses atomic_fetch_add since version 1.0.25 and
commit 1a08aa8 and commit eed8a37 but some architectures (e.g. sparc)
needs to link with -latomic to be able to use it. So check if -latomic
is needed and update libusb-1.0.pc accordingly to avoid the following
build failure with openocd:
/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/buildroot/autobuild/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libusb-1.0.so: undefined reference to `__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status
Full build log:
http://autobuild.buildroot.org/results/4a27a769bb3cdf78643c3049b87d792178d6512c
Closes #1064
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The initial enumeration should not result in hotplug events to be fired.
This is just a convenience though, API users still need to be prepared
to be notified a second time for a device that was plugged in between
libusb_init and libusb_hotplug_register_callback.
This regressed with commit 6929b82 ("Fix segmentation fault in
libusb_init() if usbi_backend.init() fails"). This commit avoids the
mentioned segmentation fault by avoiding to clean up the hotplug code if
it was not yet initialised.
Fixes #1082
Closes #1090
References #989
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
transfer->dev_handle currently has the behaviour that it will be unset
if the device is closed. The sync API uses this fact to catch an error
case.
In other cases, transfer->dev_handle will keep its value, which means
that if the transfer lives longer than the device handle, the pointer
becomes invalid.
The transfer does however keep a reference to the device, which owns the
pointer to the context. As such, we can track this reference internal to
the transfer, and it is set while the transfer is in-flight.
With this, switch the logging infrastructure to use itransfer->dev->ctx
while checking that itransfer->dev is non-NULL.
Note that this was a regression caused by 6cae9c6 ("core: update
usbi_dbg to take the context as an argument"), specifically when
resolving the context while freeing a transfer after closing a device.
Note that the transfer will now keep a reference to the device until it
is free'ed. This allows it to use the correct context for logging even
in libusb_free_transfer.
The alternative to all this would be to just explicitly pass NULL to the
log handler in libusb_free_transfer.
Fixes #1038
Closes #1073
|
|
|
|
|
|
|
|
| |
Devices can outlive their context in some cases (in particular with
python garbage collection). Guard against this by clearing the ctx
pointer so that it is not pointing to uninitialized memory.
Closes #1058
|
|
|
|
| |
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
| |
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some functions were returning e.g. -ENOMEM and the caller would check
for negative return values. However, on Haiku, contrary to modern
standards, these macros are negative, so this logic would fail. In any
case, change the function to return -1 instead. For good measure also
set errno to the appropriate value, although it is not used in the
current code.
This was discovered on Haiku builds because the value for ENOMEM is
INT_MIN which cannot be negated without overflow.
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
| |
Fixup of commit 6cae9c6
Tested-by: Xiaofan Chen <xiaofanc@gmail.com>
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
| |
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
| |
Since libusb_set_option() is variadic, there is no symbol
for it with @ appended in the DLL, and the automatic
generation of libusb-1.0.def misses it.
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
| |
Based on `git shortlog -s | cut -c8-` and a lot of manual fixups.
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
Updated by running the following on a libusb-1.0 DLL generated by MinGW32:
echo -e "LIBRARY \"libusb-1.0.dll\"\nEXPORTS" > libusb-1.0.def
strings libusb-1.0.dll | grep ^libusb | grep @ | LC_ALL=C sort | uniq | \
sed -e "s/\(.*\)@\([0-9]*\)/ \1\n \1@\2 = \1/" | LC_ALL=C sort >> libusb-1.0.def
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
| |
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
| |
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
|
|
|
|
|
|
|
|
| |
darwin_reenumerate_device_timeout() doesn't calculate elapsed microseconds, it counts the number of times the loop runs.
This results in very long timeouts.
This PR uses clock_gettime(CLOCK_MONOTONIC, ...) to calculate the elapsed time
Closes #1035
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #1032
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In some versions of macOS a pipe stall returned when setting the alternate interface
causes the interface to become unusable. To handle this case the backend was always
re-claiming the interface before clearing the pipe stall. In macOS Monterey
unconditionally re-claiming the interface leads to an error due to the process already
having exclusive access. To resolve this issue we attempt to clear the halt and only
re-claim the interface if clearing the pipe stall returns kIOUSBUnknownPipeErr. Tested
with 12.0.1 and 10.13 and get the expected results in both cases with a custom USB
device that has this behavior.
Fixes #1011
Closes #1031
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
| |
LIBUSB_OPTION_NO_DEVICE_DISCOVERY is new.
Closes #1004
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
| |
If the value is always the same we retain binary compatibility.
References #935
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 32a22069428cda9d63aa666e92fb8882a83d4515 reordered and
refactored libusb_init. This resulted in moving code outside the
default ctx lock that was unrelated to it. But this resulted in
broken error path cleanup logic that leaves the default ctx as
locked, half initialized and freed in case a libusb_set_option or
the usbi_io_init call fails.
Undo part of the previous reordering to unlock and clear the default
ctx in all error paths in libusb_init.
Closes #995
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
| |
After commit f7084fe the if clause would always be true, so remove it.
Thanks to "xloem" for reporting.
References #942
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some of the changes in commit 9c28ad2 rely on all transfers having (or
appearing to have) asynchronous completion.
However, the libusb0.sys backend of libusbk.dll performs all control
transfers synchronously and ignores any "overlapped" structure handed to
it. Our asynchronous handling will in this case be pending and
eventually time out although the USB request itself was successful.
Therefore restore the possibility of synchronous completion of control
transfers, by forcing the completion handling on a successful return
from request submission. This brings the code closer to how it was
established in commit ce95f65.
Fixes #94
Tested-by: Xiaofan Chen <xiaofanc@gmail.com>
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The default timeouts of 5 seconds used by WinUSB are cleared in
configure_endpoints(). This was not called if not at least one extra
endpoint apart from endpoint 0 existed, so that in those cases the
default timeout of 5 seconds remained in place.
Fix this by calling configure_endpoints, even if no interface specific
endpoints were found, so that it can configure endpoint 0.
Closes #963
Signed-off-by: Julian Scheel <julian@jusst.de>
[Tormod: Refactored to reduce duplicated code]
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The NZXT Kraken Z73 device has been reported to brokenly have two
identical device interface GUIDs registered. Accept such cases by
treating the ERROR_MORE_DATA return value as success and processing the
first returned GUID as if it would be the only one.
If one day we see legitimate cases of multiple GUIDs we will need to
deal with them properly.
References jdkvision/libusb#1
Closes #1010
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
kUSBReEnumerateCaptureDeviceMask was introduced in the 10.10 SDK, so
compiling on 10.9 and earlier will fail with:
os/darwin_usb.c: In function 'darwin_reenumerate_device':
os/darwin_usb.c:1749:18: error: 'kUSBReEnumerateCaptureDeviceMask' undeclared (first use in this function); did you mean 'USBReEnumerateOptions'?
options |= kUSBReEnumerateCaptureDeviceMask;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
USBReEnumerateOptions
os/darwin_usb.c:1749:18: note: each undeclared identifier is reported only once for each function it appears in
Downstream report: https://trac.macports.org/ticket/63668
Closes #1023
|
|
|
|
| |
Closes #830
|
|
|
|
| |
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
| |
References #942
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The default options configured with libusb_set_option(NULL, ...)
were only applied when the default context was created, and were
ignored when calling libusb_init() with a non-null context pointer.
Make sure the default options will be applied to all new contexts. This
is important when using LIBUSB_OPTION_NO_DEVICE_DISCOVERY which must
be respected during the context initialization in order to work.
Closes #942
[Tormod: amend comments]
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
| |
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
| |
Found via `codespell -q 3`
Closes #1015
|
|
|
|
|
|
| |
Also inform about reading OS string descriptor.
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
| |
Other code checks this field for being NULL or not, so NULLing it upon
last release seems the right thing to do. I noticed this during code
review, I never actually reproduced any problem.
Closes #981
|
|
|
|
| |
Closes #1013
|
|
|
|
|
|
| |
Closes #1005
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The standard procedure to define ssize_t on Windows is to wrap it around
a check for the _SSIZE_T_DEFINED macro.
If not done, it makes it impossible to use the libusb.h header along
with other headers (from other libraries) that also attempt to define
ssize_t.
Closes #1007
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
|
|
|
|
|
|
|
|
| |
This only fixes issue (A):
libusb: error [composite_copy_transfer_data] program assertion failed - no function to copy transfer data
References #966
Closes #967
|
|
|
|
|
|
|
|
| |
The kIOMasterPortDefault constant has been replaced by kIOMainPortDefault. Both
are synonmys for 0. To avoid extra checks on the target macOS release just go
ahead and use 0.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
| |
With macOS Monterey Apple started using a new error code to indicate a pipe
stall. This new error code needs to be handled both in translation to libusb
error codes and when handling errors setting the alt setting.
References #1011
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
| |
"source" is not supported in Bourne shell
Closes #997
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
| |
Add another approach for connecting USB devices on Android.
References #830
Closes #996
|
|
|
|
|
|
|
|
|
| |
If the backend init fails, the control goes to err_io_exit which tries
to clean up hotplug related lists that aren't initialized. Moving
hotplug_init before makes sure the lists are valid so if backend init
fails they get cleaned up without errors.
Closes #989
|
|
|
|
| |
References #981
|
|
|
|
|
|
|
|
| |
Fixes #31
See #143 and #596 for solutions to the whole build system.
Closes #971
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the report id is zero, we should indeed skip the first byte of
transfer_priv->hid_buffer, since it is not part of the actual report.
But the report size should not change.
Thanks to Jonas Malaco who has done the investigation in this issue.
Reference: Jonas Malaco's comments
https://github.com/libusb/libusb/issues/902#issuecomment-810726897
Fixes #902
Fixes #977
Closes #986
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
| |
Detaching a kernel driver in macOS requires that either the binary has the
com.apple.vm.device-access entitlement or is run with effective UID 0 (root). This
commit adds an effective UID check before attempting to capture a device and prints
a warning that neither is the user root nor does the binary have the correct
entitlement.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
This commit restores the ability to capture-open a USB device when running as root.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|