| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Closes #1155
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
This commit adds a call to libusb_kernel_driver_active and prints out the result. This
provides a way to quickly check the result when testing.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #151
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are certain games played in the examples and tests source to
account for differences in build environments and target platforms. This
can be simplified by including config.h and using the definitions there.
To that end, move the printf function attribute definition from
libusbi.h to config.h and leverage it where it is used in the examples
and tests.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit f69548c3b3 ("examples: Enable all examples to build on all
platforms") modified dpfp and sam3u_benchmark to be buildable on any
platform, however there were some oversights and regressions introduced
for Android and Xcode.
Update the Android and Xcode build files to account for the removal of
dpfp_threaded.c as well as the inclusion of config.h from examples
and/or tests source.
Additionally switch the threaded version of dpfp to use sem_open()
instead of sem_init() as the latter is in fact deprecated on MacOS.
Closes #808
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this change, the dpfp and sam3u_benchmark examples were only
built on POSIX platforms due to a dependency on sigaction(). Furthermore
the dpfp_threaded example only worked with POSIX threads.
Lift this limitation by breaking the dependence on sigaction(). Also
provide a minimal threading abstraction so that dpfp_threaded can be
built on Windows as well.
Also merge the sources for dpfp and dpfp_threaded. The only difference
between the two is how libusb's event handling functions are called and
this can be easily handled within a single source file.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* [-Wpointer-arith] arithmetic on a pointer to void is a GNU extension
* [-Wswitch-enum] enumeration values 'E1, ...' not explicitly handled in switch
* [-Wunused-parameter] unused parameter 'p'
For '-Wswitch-enum', the switch statements in the individual backends'
set_option() function has been removed. It is not expected that backends
will need to handle or be aware of all the options.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
| |
Print the speed of devices to exercise libusb_get_device_speed().
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
|
|
|
|
| |
Sometimes it is useful to be able to test libusb_wrap_sys_device(),
add support for this to the testlibusb example
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The split between events and threads abstractions is unnecessary.
Simplify the library by merging the two into a "platform" abstraction.
The only meaningful change is that Cygwin builds will no longer use the
POSIX threads abstraction but will instead use the native Windows one.
The downside to doing this is that the dpfp_threaded example program
will no longer be available on Cygwin builds. This should be fine, and
future work will make dpfp_threaded available for all forms of Windows
build systems.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
| |
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are a few parts within the library where code is conditionally
compiled based on whether or not the target OS is Windows. Prior to
commit 8b09dd490d ("core: Kill the OS_* definitions and use in the
source code"), the OS_WINDOWS definition was used. With that definition
gone, the checks were replaced with _WIN32. Unfortunately the different
cross-platform toolchains do not universally define this, so add this to
AM_CPPFLAGS when building for Windows.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add '-fvisibility=hidden' to the additional compiler flags of the libusb
target so that internal library symbols are hidden.
Add '-pthread' to the additional compiler flags of the targets that
directly use pthread functionality
Add the 'sam3u_benchmark' and 'testlibusb' targets so that all examples
are now built and fix build warnings that occur when building
'sam3u_benchmark'.
Fix target dependencies so that all targets are able to build without
issues.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Help catch more errors by enabling additional build errors and warnings.
Address some of the warnings seen with these new flags, including moving
the libusb_transfer structure back out of the usbi_transfer structure to
address 'warning: invalid use of structure with flexible array member'.
Apparently a structure ending with a flexible array member is not okay
with the compiler as the last member within another structure.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
C11 compiler support has been available for many years now. It is not
unreasonable to require this now, and doing so allows some cleanup to
the configure script. It is no longer necessary to check for compiler
support of the '-fvibility' flag because any compiler that supports C11
will support this flag as well.
Fix up the way that compiler and linker flags are passed down to the
various makefiles. The compiler flags should be shared by all, but the
linker flags and libraries should be separated between the library and
the examples/tests. The visibility flag is only relevant for the
library and the thread flags are only relevant for sources using thread
constructs, so provide them as needed.
Rearrange configure.ac to group similar functionality and consolidate
where possible.
Based on these changes, update the Travis configuration file to include
newer versions of test platforms to ensure proper C11 compiler support.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since Visual Studio picks the first project as the default startup
project, move the library projects back to the top of the list. This use
to be the order but was changed in commit 9843b689df.
Add the project filter files to help organize the source files within
the Solution Explorer window pane.
Additionally move the getopt source underneath the msvc directory since
it is only used for Visual Studio builds.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
There appears to be no need for the WinCE backend anymore, and it is
increasingly difficult to keep healthy as the rest of the library
changes.
Require at least Visual Studio 2013 to compile. This simplifies matters
as there is some semblance of C99 support there.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Previously the program would only print the VID when the manufacturer
string is unavailable and the PID when the product string is
unavailable. Change this to print the VID and PID unconditionally and
print the manufacturer and product strings similar to how the serial
number string is being printed. In addition, line up the string values
with the rest of the output.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Make the coding style and whitespace consistent with the rest of the
library source code.
In the print_device() function, the 'level' argument is unnecessary, so
remove it and the associated space padding. Switch to use printf()
directly instead of formatting the description into a single buffer.
This not only simplifies the code but avoids truncating the description
for devices with larger descriptor strings.
Make the output formatting consistent by lining up all the printed
values and using the same notation for all hexadecimal values.
Inspired by PR #452, enable printing all available BOS device
capability descriptors, not just the first one.
Closes #452
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
| |
Closes #530
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
| |
- added various casts
- added some asserts where the casts made assumptions
- enabled additional warnings in Xcode project (especially -Wshorten-64-to-32)
Closes #509
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As description is used only for debug, we can extend it to be sure to
fit 256 from string variable plus 3 chars from " - " as described in
gcc warning below
| testlibusb.c: In function ‘print_device.constprop’:
| testlibusb.c:188:51: warning: ‘ - ’ directive output may be truncated writing 3 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
| snprintf(description, sizeof(description), "%s - ", string);
| ^~~
| testlibusb.c:188:5: note: ‘snprintf’ output between 4 and 259 bytes into a destination of size 256
| snprintf(description, sizeof(description), "%s - ", string);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Closes #460
Signed-off-by: Victor Toso <victortoso@redhat.com>
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
|
|
|
|
|
|
| |
Closes #448
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
|
|
|
|
| |
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Specifically:
redundantAssignment,examples/dpfp.c:422,style,Variable 'r' is reassigned a value before the old one has been used.
redundantAssignment,libusb/os/threads_posix.c:64,style,Variable 'ret' is reassigned a value before the old one has been used.
unreadVariable,libusb/os/netbsd_usb.c:217,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/netbsd_usb.c:235,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/openbsd_usb.c:251,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/openbsd_usb.c:275,style,Variable 'hpriv' is assigned a value that is never used.
unsignedLessThanZero,libusb/os/windows_winusb.c:259,style,Checking if unsigned variable '_index' is less than zero.
unsignedLessThanZero,libusb/os/windows_winusb.c:298,style,Checking if unsigned variable '_index' is less than zero.
unsignedLessThanZero,libusb/os/windows_winusb.c:367,style,Checking if unsigned variable '_index' is less than zero.
invalidPrintfArgType_sint,examples/xusb.c:534,warning,%d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
| |
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
| |
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
| |
Fixes clang -Wreserved-id-macro warning.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
| |
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
| |
Make data that is unchanged const, remove an unused return value, and
add a missing newline to an error message.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As noted in issue #269, the current xusb implementation does not handle
Microsoft OS descriptors from devices whose vendor code is greater than
0x7F. This commit addresses this limitation by using
libusb_get_string_descriptor() instead of the ASCII variant and parsing
the descriptor separately. Note that this issue was addressed in PR #276,
but that approach was too cryptic to read.
Closes #269, Closes #276
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The CALL_CHECK macro returns from the current function, so in the
test_device() function the device handle was being leaked when one of
the functions failed. This commit adds a new CALL_CHECK_CLOSE macro that
does the same as CALL_CHECK but also closes the device handle before
returning. In addition, the macros are changed to declare their needed
variable rather than relying on the variable to already exist within the
scope of the function.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This new function allows more flexibility in extending the library to
support more user-configurable options. It is intended to provide a
single API that can support a wide variety of needs and eliminates the
need for new API functions to set future options.
The function is introduced with a single option (LIBUSB_OPTION_LOG_LEVEL)
that replaces the libusb_set_debug() function. Documentation relating to
libusb_set_debug() and the uses of this function in the examples and
tests have been updated accordingly.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
| |
convert from DOS to Unix text format
remove extra spaces at end of line
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
| |
OS X does not support unnamed semaphores so the example has been
updated to use a named semaphore instead.
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
| |
This commit is based on Nathan's branch
https://github.com/hjelmn/libusb-darwin/blob/master/examples/testlibusb1.c
Closes #178
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
examples/hotplugtest.c:76:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
vendor_id = (argc > 1) ? strtol (argv[1], NULL, 0) : 0x045a;
~ ^~~~~~~~~~~~~~~~~~~~~~~~~
examples/hotplugtest.c:77:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
product_id = (argc > 2) ? strtol (argv[2], NULL, 0) : 0x5005;
~ ^~~~~~~~~~~~~~~~~~~~~~~~~
examples/hotplugtest.c:78:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
class_id = (argc > 3) ? strtol (argv[3], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
~ ^~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
| |
This fixes compiling libusb with uclibc.
Closes #141, #165
Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fxload.c:202:17: warning: comparison of integers of different signs: 'int' and
'unsigned long' [-Wsign-compare]
...for (j=0; j<ARRAYSIZE(known_device); j++) {
~^~~~~~~~~~~~~~~~~~~~~~~~
fxload.c:222:12: warning: comparison of integers of different signs: 'int' and
'unsigned long' [-Wsign-compare]
if (j < ARRAYSIZE(known_device)) {
~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
fxload.c:263:13: warning: comparison of integers of different signs: 'int' and
'unsigned long' [-Wsign-compare]
for (i=0; i<ARRAYSIZE(path); i++) {
~^~~~~~~~~~~~~~~~
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
sam3u_benchmark.c:54:17: warning: comparison of integers of different signs:
'unsigned int' and 'int' [-Wsign-compare]
for (i = 0; i < xfr->num_iso_packets; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~~~
sam3u_benchmark.c:67:16: warning: comparison of integers of different signs:
'unsigned int' and 'int' [-Wsign-compare]
for (i = 0; i < xfr->actual_length; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ezusb.c:136:13: warning: comparison of integers of different signs: 'int' and
'size_t' (aka 'unsigned long') [-Wsign-compare]
if (status != len) {
~~~~~~ ^ ~~~
ezusb.c:159:13: warning: comparison of integers of different signs: 'int' and
'size_t' (aka 'unsigned long') [-Wsign-compare]
if (status != len) {
~~~~~~ ^ ~~~
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
| |
|
|
|
|
|
|
|
|
| |
* Add two-stage load support
* Fix leaks in error-handling paths
* Closes #12
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
| |
* Use sig_atomic_t as data type for variable do_exit
* Use async-safe function within signal handler
Closes #34
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|