1967 Commits

Author SHA1 Message Date
squidbus
c4d237a580 More ABI fixes 2025-09-07 13:56:12 -07:00
squidbus
d3e6a718b1 Apply SysV ABI attribute more broadly. 2025-09-07 13:39:44 -07:00
georgemoralis
e1f4ac1472 fixed CMakeLists 2025-07-21 00:14:29 +03:00
georgemoralis
d8665429a2 added cmakelists 2025-07-20 23:44:07 +03:00
georgemoralis
1dee71ecf9 Merge pull request #1 from connorh315/callback-abi-fix
Enforce correct ABI in callback
2025-07-20 22:58:05 +03:00
Connor Harrison
0ee992db26 Enforce correct ABI in callback 2025-07-19 21:47:31 +01:00
Sean McBride
3dbfa16f0c core: Remove some unnecessary consts
The const in the libusb_cpu_to_le16() function declaration was useless.

The consts in the libusb_version struct did have an effect, but were
overly restrictive.

Closes #1540
2025-06-09 23:18:54 +02:00
Sean McBride
d1e4372464 libusbi.h/darwin: Split recursive struct declarations, for C++ compat
Closes #1461
2025-06-09 22:55:10 +02:00
Sean McBride
40c5799881 darwin: Introduce temporary variable so we can take the address
For C++ compatibility

References #1461
2025-06-09 22:54:23 +02:00
Sean McBride
1b1639eeee darwin: Fix last param to QueryInterface to be LPVOID*
Per its declaration (also for C++ compat)

References #1461
2025-06-09 22:53:35 +02:00
Tormod Volden
f52a9c0c4d examples/hotplugtest: Close old device only if new one was opened
We want to keep only one device open for simplicity, but instead of
closing the last opened device already before /trying/ to open a new
one, close it only if the new one was opened successfully. This way
we may keep the device open longer, and in the simple case where no
later arriving devices could be opened, until it is detached again.

Closes #1550

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-06-09 15:43:48 +02:00
Tormod Volden
6c41069e77 examples/hotplugtest: Allow multiple devices attaching
If no device ID is specified, and for instance a hub is plugged, many
devices will be attached (and later detached) at the same time. The old
code counting only 2 events would then exit prematurely.

By counting attach and detach events separately, we preserve the old
behaviour in the single-device case, but also allow more complex
sequences to be handled in a way that mostly appears intuitive.

This is not fool-proof, and we can still end up leaving after a surprise
detachment of a "pre-existing" device while we have one of the "new"
devices open. In this case print a warning.

References #1455

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-06-09 15:43:16 +02:00
Ingvar Stepanyan
4b9cf1fb04 tests: Fix Node.js shim for Node 21+ (webusb/emscripten)
Fixes #1648
Closes #1656
2025-06-09 11:02:57 +02:00
Tormod Volden
15a7ebb4d4 libusb 1.0.29 2025-06-01 20:33:14 +02:00
Tormod Volden
53a4c0ab68 docs: Document SuperSpeedPlus device capability functions
Follow-up of #1428 and #1545

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-06-01 19:08:37 +02:00
Tormod Volden
ed09a92b0b xusb: Fix error reporting on interface claim
There was a mixup of "ret" and "r", so use "r" consistently as
in the rest of the function.

Closes #1636

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-05-16 01:17:04 +02:00
Oleksand Radovenchyk
083f0cbfe4 chore: Remove broken or stale build badges from README
Closes #1640
2025-05-16 00:35:38 +02:00
Tormod Volden
94e0d8c2aa Bump LIBUSB_API_VERSION
1.0.28 shipped with new SuperSpeed+ functions, but the
LIBUSB_API_VERSION macro had unfortunately not been changed.

Fixes #1642

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-05-16 00:33:40 +02:00
Zeng Guang
9cef804b24 darwin: Fix regression causing re-enumeration timeout
Fix time calculation for negative nanosecond deltas to resolve
re-enumerate timeout. Fixup of commit a07ecfe02.

Fixes #1637
References #1610
2025-05-03 12:08:40 +02:00
Tormod Volden
c6c45b8e8c docs: Refer to Topics instead of Modules
doxygen generates a "Topics" instead of "Modules" button these days.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-05-03 11:31:07 +02:00
Tormod Volden
a61afe5f75 libusb 1.0.28
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-03-18 23:07:26 +01:00
Tormod Volden
20f6f37164 configure.ac: Bump libtool library version
Programs using the previous version may use the new version as drop-in
replacement, but programs using the new version may use APIs not present
in the previous one.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-03-18 23:04:49 +01:00
Tormod Volden
1496324291 core: Avoid infinite recursion on invalid LIBUSB_DEBUG value
Silently ignore invalid values, since we cannot use logging inside
the get_env_debug_level() function.

Fixes #1619

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-03-18 09:54:55 +01:00
Tormod Volden
12bd342473 libusb 1.0.28-rc1
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2025-03-06 21:47:29 +01:00
Jesse Taube
0e0a072220 CI: Remove build job for MSYS clang32
Upstream dropped support for clang32, and our CI build already
fails on it, so remove the build job.

https://github.com/msys2/setup-msys2/pull/458

Closes #1607

Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
2025-03-02 20:43:44 +01:00
Radu Vele
de38189e80 Enable linux netlink event monitoring for Android OS platform services
Introducing the ANDROID_OS macro that is supposed to be set by clients
of libusb that are running on Android at the OS level.

If Android_OS is set (and HAVE_LIBUDEV is not) then linux netlink event
monitoring (and consequently hotplug functionality) is enabled. This
works for Android services or simple binaries running at the OS level as
they have the necessary permissions, in contrast to usual Android apps
(see commit 2f3bc98).

Note: the __ANDROID__ macro is set by GCC for all targets running on
Android (both OS-level services and apps).

Closes #1577

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
2024-11-13 21:16:58 -07:00
Fabien Sanglard
7bc88c0f08 macos: Fix Zero-Length Packet for multiple packets per frame
Summary of problem:

The LIBUSB_TRANSFER_ADD_ZERO_PACKET flag does not work as expected on
Darwin. On my USB 3 device, with maxPacketSize = 1024, I see libusb
sending ZLP for packets multiple of 5120 instead of 1024.

The ZLPs are not being sent when they should because
darwin_get_pipe_properties() retrieve the "full" wMaxPacketSize via
GetPipePropertiesV3(), which includes bandwidth multipliers.

Summary of solution:

GetEndpointPropertiesV3() does retrieve unaltered wMaxPacketSize,
without multipliers. To call it, we first use GetPipePropertiesV3() to
set the fields required.

Fixes #1581
Closes #1582
2024-11-13 19:33:24 +01:00
Tormod Volden
7adb2913ce docs: Fix broken doxygen references
Fixup of commit d7b796f1

References #1549

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2024-11-13 11:07:55 +01:00
Tormod Volden
0b4eda697f docs: Hide internal descriptor.c structure from doxygen
Follow-up of commit f00f06e9

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2024-11-13 10:57:56 +01:00
Fabien Sanglard
28a6afb690 docs: Document internal_ssplus_capability_descriptor
Also include SSP documentation fixups of commit f00f06e9
that had introduced Doxygen errors.

Closes #1545
2024-11-13 10:57:49 +01:00
Matthijs Lavrijsen
467b6a8896 winusb: Fix winusb_get_device_list() failing to find port numbers
Fix recent regression introduced in commit 9d595d4.

get_dev_port_number() was always returning port number 0 for any port,
due to the incorrect assumption that strtoll's 'end' pointer will point
to a null terminator on success. This was causing
winusb_get_device_list() to always fail. Since we actually know the
expected values of *end for both the SPDRP_LOCATION_INFORMATION and the
SPDRP_LOCATION_PATHS case, check for those instead.

Additionally, document why a return value of 0 is treated as a failure
in this particular function, for valid but somewhat coincidental reasons
that may not be immediately obvious.

Closes #1544
2024-07-31 00:05:01 +02:00
Sean McBride
8776b8021a descriptor: Fix clang -Wimplicit-int-conversion warnings
For the 16-bit case especially, the result of the `or` is implicitly
promoted to `int`, then when returned was warning:

warning: implicit conversion loses integer precision: 'int' to 'uint16_t' (aka 'unsigned short') [-Wimplicit-int-conversion]

Add more casts to shut it up.

Closes #1541
2024-07-30 00:57:06 +02:00
Sean McBride
a3199696e2 xcode: Adjust file indentation settings
Change tab vs space and 2 vs 8 intent in Xcode project to match the
emacs metadata at the top of the files.

Closes #1543
2024-07-30 00:54:21 +02:00
Sean McBride
30ec25f738 examples/ezusb: Fix error checking regression in recent commit
Commit 00454ab0 accidently botched error checking when replacing
rewind() with fseek().

Thanks to GitHub user "anotheruserofgithub" for noticing.

Closes #1539
2024-07-29 19:55:01 +02:00
Tormod Volden
4528752cbe windows: Base HID device descriptor on cached values
Instead of filling in the blanks with hard-coded made-up values that are
sometimes correct, use the cached descriptor values retrieved during
enumeration, which should be a better fallback.

References #1360
Closes #1378

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2024-07-28 14:25:22 +02:00
Tormod Volden
d04fc0e60b openbsd: Use default clause in _errno_to_libusb()
Same as for NetBSD.

Closes #1295

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2024-07-28 14:22:20 +02:00
Tormod Volden
bc12cda784 netbsd: Debug print all errors
Same as for OpenBSD.

References #1295

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2024-07-28 14:21:32 +02:00
Sean McBride
9d595d4e4a Replace atoi() with strtol() which allows error checking
atoi() gives no opportunity for error checking, strtol() does. Improved
error checking.

Closes #1422
2024-07-28 14:12:07 +02:00
Tormod Volden
bd0fcdb4c2 Add KEYS file for release files verification
Include my own public key, used for 1.0.25/1.0.26/1.0.27 already.

The KEYS file is inspired by the Apache project:
https://infra.apache.org/release-signing#keys-policy

References #1469

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2024-07-28 14:04:37 +02:00
Yiwei Lin
c3873d5c2c xusb: Define proper exit status
Consider different scenario to return from main, we have to choose the
proper return value. In this way, we can easily check the return code
directly like `echo $?` in Linux to know whether the execution of xusb
is failed.

Closes #1507

Signed-off-by: Yiwei Lin <s921975628@gmail.com>
2024-07-28 13:52:17 +02:00
Sean McBride
e8d76b1a12 clang-tidy: Stop suppressing readability-misleading-indentation warnings
All such warnings are already fixed in master.

Closes #1479
2024-07-28 13:27:06 +02:00
Sean McBride
197e3052cd libusb.h: Match parameter names in declaration and definition
Took the name from the .c file.

Fixes all clang-tidy readability-inconsistent-declaration-parameter-name
warnings

References #1479
2024-07-28 13:27:06 +02:00
Sean McBride
55f8c95551 descriptor: Fix addition overflow by correcting casts
The addition could overflow, the upcast needs to be performed before,
not after.

Fixes all clang-tidy bugprone-misplaced-widening-cast warnings

References #1479
2024-07-28 13:27:06 +02:00
Sean McBride
e3ccc46b6e descriptor: Eliminate all duplicate branch bodies, as they are bug-prone
Copy-pasting can often result in mistakes like:

```
if (test_value(x)) {
  y++;
  do_something(x, y);
} else {
  y++;
  do_something(x, y);
}
```

Thus it is preferable that branch bodies be unique.

Fixes all clang-tidy bugprone-branch-clone warnings

References #1479
2024-07-28 13:27:06 +02:00
Sean McBride
9cf84577ce Avoid assignments within if statements
Fixes all clang-tidy bugprone-assignment-in-if-condition warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
a18a964aba darwin: Fix multiplication overflow by better matching type sizes
These multiplication could indeed have overflowed, but now they are
performed with a bigger type, matching the type they are ultimately
stored in.

Fixes all clang-tidy bugprone-implicit-widening-of-multiplication-result
warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
6883f84f93 darwin: Explicitly compare string compare function results to -1, 0, or 1
Fixes all clang-tidy bugprone-suspicious-string-compare warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
418aadc0f9 darwin: Always use uppercase literal suffixes for improved readability
Depending on the font, an l suffix can look like a 1. Consider "231l".
Thus prefer uppercase.

Fixes all clang-tidy readability-uppercase-literal-suffix warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
3616e751b1 examples/xusb: Match size of loop index to what is iterated
Fixes all clang-tidy bugprone-too-small-loop-variable warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
a7e471dd48 examples/xusb: Make some parameters const where possible
Fixes all clang-tidy readability-non-const-parameter warnings

References #1479
2024-07-28 13:27:05 +02:00