Pete Batard [Thu, 21 Feb 2013 00:24:18 +0000 (00:24 +0000)]
Tests: Simplify stdout redirection and fix Windows assertion error on cleanup
* cleanup_test_output() produced an assertion error when compiled with MSVC
due to closing ctx->output_file
* set ctx->output_file to stdout by default
Pete Batard [Thu, 21 Feb 2013 00:11:37 +0000 (00:11 +0000)]
Windows: Don't duplicate paths for HID interfaces
* This caused the many_device_lists to fail after 32 iterations
* Closes #69
Pete Batard [Mon, 18 Feb 2013 22:22:01 +0000 (22:22 +0000)]
Windows: Fix broken WDK compilation
*
790ffc78b008a03c95d10899f53997b504f55c72 moved the inclusion of poll_windows.h
after the use of struct timeval, which removed the hidden winsock.h include
where timeval is defined on the WDK.
* Make the winsock.h include explicit
Ludovic Rousseau [Mon, 18 Feb 2013 19:29:41 +0000 (20:29 +0100)]
Windows: fix compiler warning
libusb/os/threads_windows.c:139:1: warning: '__inline' is not at beginning of declaration [-Wold-style-declaration]
Ludovic Rousseau [Mon, 18 Feb 2013 19:26:46 +0000 (20:26 +0100)]
Windows: fix compiler warning
libusb/os/threads_windows.c: In function 'usbi_cond_timedwait':
libusb/os/threads_windows.c:190:2: warning: nested extern declaration of 'epoch_time' [-Wnested-externs]
Ludovic Rousseau [Sat, 16 Feb 2013 16:23:36 +0000 (17:23 +0100)]
Windows: fix compiler warning
sizeof() returns a size_t not an int
libusb/os/windows_usb.c:1411:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libusb/os/windows_usb.c:1416:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Ludovic Rousseau [Sat, 16 Feb 2013 16:07:53 +0000 (17:07 +0100)]
Windows: fix compiler warnings
libusb/os/windows_usb.c:1317:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:1317:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:1317:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:3634:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:3634:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
libusb/os/windows_usb.c:3634:2: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
Ludovic Rousseau [Sat, 16 Feb 2013 16:04:59 +0000 (17:04 +0100)]
Windows: remove useless extern declaration
libusb/os/windows_usb.c:45:13: warning: redundant redeclaration of 'usbi_fd_notification' [-Wredundant-decls]
libusb/libusbi.h:420:6: note: previous declaration of 'usbi_fd_notification' was here
Ludovic Rousseau [Sat, 16 Feb 2013 16:02:40 +0000 (17:02 +0100)]
Windows: fix compiler warnings
libusb/os/windows_usb.c:368:36: warning: no previous prototype for 'get_interface_details_filter' [-Wmissing-prototypes]
libusb/os/windows_usb.c:691:5: warning: no previous prototype for 'get_sub_api' [-Wmissing-prototypes]
libusb/os/windows_usb.c:1179:6: warning: no previous prototype for 'get_api_type' [-Wmissing-prototypes]
Ludovic Rousseau [Sat, 16 Feb 2013 16:00:32 +0000 (17:00 +0100)]
Windows: remove unused function
libusb/os/poll_windows.c:223:13: warning: 'reset_overlapped' defined but not used [-Wunused-function]
Ludovic Rousseau [Sat, 16 Feb 2013 15:58:17 +0000 (16:58 +0100)]
Windows: fix compiler warnings
libusb/os/poll_windows.c:176:5: warning: no previous prototype for '_fd_to_index_and_lock' [-Wmissing-prototypes]
libusb/os/poll_windows.c:197:13: warning: no previous prototype for 'create_overlapped' [-Wmissing-prototypes]
libusb/os/poll_windows.c:211:6: warning: no previous prototype for 'free_overlapped' [-Wmissing-prototypes]
libusb/os/poll_windows.c:223:6: warning: no previous prototype for 'reset_overlapped' [-Wmissing-prototypes]
libusb/os/poll_windows.c:401:6: warning: no previous prototype for '_free_index' [-Wmissing-prototypes]
Ludovic Rousseau [Wed, 17 Oct 2012 16:01:59 +0000 (18:01 +0200)]
Examples: Fix compiler warning
examples/ezusb.c:251:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
off = strtoul(buf+3, NULL, 16);
~ ^~~~~~~~~~~~~~~~~~~~~~~~
Ludovic Rousseau [Sat, 13 Oct 2012 18:22:49 +0000 (20:22 +0200)]
Core: Fix compiler warning
libusb/io.c:1877:35: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
timeout_ms = (tv->tv_sec * 1000) + (tv->tv_usec / 1000);
~ ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
On Mac OS X tv_sec is a __darwin_time_t which is a long, not an int.
Sean McBride [Wed, 31 Oct 2012 15:09:31 +0000 (11:09 -0400)]
Use "" instead of <> for internal includes
some libusbx include files were included with angle brackets, changed to
quotes. Needed to work better in Xcode project
Toby Gray [Wed, 13 Feb 2013 15:21:52 +0000 (15:21 +0000)]
Windows: Update transferred data on timeout or cancel.
* When handling aborted transfer it's possible that some data (but not
the full buffer) was transferred.
* This change ensures that this partially transferred data is recorded
and passed up to the caller.
Hans de Goede [Mon, 11 Feb 2013 15:21:00 +0000 (15:21 +0000)]
Linux: Don't set the USBFS_URB_SHORT_NOT_OK flag on the last urb
* Closes #142
Pete Batard [Sat, 2 Feb 2013 01:02:18 +0000 (01:02 +0000)]
Windows: Improve error reporting in winusbx_claim_interface()
* After the filter detection code is run, the error reported may
have nothing to do with the original error (or report SUCCESS)
and is unhelpful
* Also change TODO comments to default VS2012 task style
Benjamin Dobell [Fri, 1 Feb 2013 14:42:06 +0000 (01:42 +1100)]
Windows: Fixed bug in interface autoclaim
* Bug was introduced in
f2b19e4a32c1445f4fea06beca61e8c7e7757950
* Closes #78
* Closes #80
Ludovic Rousseau [Fri, 26 Oct 2012 08:02:16 +0000 (10:02 +0200)]
Core: Fix warning implicit conversion changes signedness
* Closes #70
Zoltán Kovács [Tue, 29 Jan 2013 00:14:29 +0000 (00:14 +0000)]
Core: Don't wait for completion if cancel_transfer failed
* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-libusb-interrupt-transfer-does-not-return-in-case-of-error-td626.html
* Closes #76
Pete Batard [Mon, 28 Jan 2013 23:51:53 +0000 (23:51 +0000)]
Windows: Display error code in default case of windows_transfer_callback
Toby Gray [Wed, 16 Jan 2013 02:10:31 +0000 (02:10 +0000)]
WinCE: Add support for WinCE (Solution files)
Toby Gray [Wed, 16 Jan 2013 02:07:29 +0000 (02:07 +0000)]
WinCE: Add support for WinCE (sources)
Toby Gray [Tue, 15 Jan 2013 22:46:49 +0000 (22:46 +0000)]
Windows: Simplify poll_windows and add provisions for WinCE
* Because poll_windows now requires struct usbi_transfer to be
defined, it's inclusion in libusbi.h had to be moved down.
Toby Gray [Tue, 15 Jan 2013 22:36:47 +0000 (22:36 +0000)]
Windows: Add windows_common.h header
* This file contains definition that will be shared between the
Windows and Windows CE backends
Pete Batard [Tue, 15 Jan 2013 22:24:32 +0000 (22:24 +0000)]
Core: Use HAVE_SYS_TYPES_H and HAVE_SIGNAL_H
* These files may not be available on all platforms (eg. WinCE)
Роман Донченко [Fri, 21 Dec 2012 23:08:09 +0000 (03:08 +0400)]
Core: Filter out 8-bit characters in libusb_get_string_descriptor_ascii
* Closes #68
Pete Batard [Mon, 7 Jan 2013 22:00:47 +0000 (22:00 +0000)]
Windows: Add VS2012 solution files
* As well as try to clean up MS's MSVC mess...
Toby Gray [Mon, 26 Nov 2012 13:25:05 +0000 (13:25 +0000)]
Core: Fix incorrect reference counting of default context when first created.
* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-stress-program-crashes-in-libusb-exit-NULL-tp474p477.html
Toby Gray [Wed, 21 Nov 2012 14:00:31 +0000 (14:00 +0000)]
Tests: Add libusbx stress test
See https://github.com/tobygray/libusbx/tree/testing as well
as http://libusbx.1081486.n5.nabble.com/Libusbx-devel-Crashes-tt433.html#a438
Peter Stuge [Tue, 23 Oct 2012 00:15:23 +0000 (00:15 +0000)]
Autotools: Carry over 2012.10.23 libusb changes
* Use LIBS instead of PC_LIBS_PRIVATE
* Move THREAD_CFLAGS & VISIBILITY_CFLAGS into AM_CFLAGS
* Use AC_SEARCH_LIBS(clock_gettime) for pthreads on Linux
Peter Stuge [Tue, 30 Oct 2012 00:11:41 +0000 (00:11 +0000)]
Core: Avoid short read failures on broken descriptors
* See http://marc.info/?t=
135132844600001&r=1&w=2
Sean McBride [Thu, 8 Nov 2012 19:02:06 +0000 (19:02 +0000)]
Darwin: kAppleVendorID is not in the 10.5 SDK
* Use kIOUSBVendorIDAppleComputer instead
Nathan Hjelm [Wed, 31 Oct 2012 22:54:07 +0000 (22:54 +0000)]
Darwin: Clean up tabs
* Closes #55
Nathan Hjelm [Tue, 2 Oct 2012 14:07:03 +0000 (08:07 -0600)]
Darwin: Add support for detecting superspeed devices
* IOUSBFamily 5.0.0 or newer
Nathan Hjelm [Sat, 29 Sep 2012 04:13:09 +0000 (22:13 -0600)]
Darwin: Use Release instead of IODestroyPlugInInterface
* This avoids stopping IOServices associated with a device
* Closes #54
Nathan Hjelm [Sat, 29 Sep 2012 03:18:36 +0000 (21:18 -0600)]
Darwin: Don't retry or unsuspend Apple devices during enum
Nathan Hjelm [Sat, 29 Sep 2012 03:18:08 +0000 (21:18 -0600)]
Darwin: Reduce attempts to retrieve a device descriptor during enumeration
Sean McBride [Thu, 25 Oct 2012 18:51:50 +0000 (14:51 -0400)]
Core: Use offsetof() instead of null pointer tricks
Closes #53
Pete Batard [Mon, 29 Oct 2012 23:41:23 +0000 (23:41 +0000)]
Windows: Fix access for composite HID devices
* composite_open was only catering for interfaces with WinUSB-like
drivers and did not properly initialize HID driven ones
* Issue reported by Stefano Di Martino
Ludovic Rousseau [Fri, 12 Oct 2012 21:28:51 +0000 (23:28 +0200)]
All: Use "" instead of <> for local includes
System header files are used with #include <foo.h>
Xcode can't find local headers using this syntax.
Pete Batard [Wed, 3 Oct 2012 22:52:16 +0000 (23:52 +0100)]
Windows: Fix early abort in libusb_close
* We're calling winusbx_close with SUB_API_NOTSET, so
we should attempt to initialize it first.
* Issue reported by Ramon Zambelli and Frank Hibbeln
Pete Batard [Mon, 24 Sep 2012 23:35:32 +0000 (00:35 +0100)]
libusbx-1.0.14
Pete Batard [Thu, 20 Sep 2012 20:58:04 +0000 (21:58 +0100)]
libusbx-1.0.13
Pete Batard [Wed, 19 Sep 2012 21:22:24 +0000 (22:22 +0100)]
Internal: Add fxload exe and sources to the Windows binary snapshot
Pete Batard [Tue, 18 Sep 2012 20:35:23 +0000 (21:35 +0100)]
Misc: Update copyrights, TODO and libusb_version.describe
* Changes suggested by Chuck Cook & Xiaofan Chen
Pete Batard [Sun, 16 Sep 2012 15:24:24 +0000 (16:24 +0100)]
libusbx 1.0.13-rc2
* Also update NEWS with regards to isoc support for the 0/K Windows drivers
Pete Batard [Sun, 16 Sep 2012 15:19:54 +0000 (16:19 +0100)]
Doc: Fix doxygen warnings and issues
* Remove obsolete tags
* Use QUIET = yes to make issues more prominent
* Fix code display for LIBUSBX_API_VERSION and missing parameter
documentation for libusb_get_port_path()
* Most of the above suggested by Ludovic Rousseau
Pete Batard [Sun, 16 Sep 2012 15:11:10 +0000 (16:11 +0100)]
Misc: Fix missing files from dist package
Pete Batard [Sat, 15 Sep 2012 23:16:06 +0000 (00:16 +0100)]
libusbx 1.0.13-rc1
Pete Batard [Sat, 15 Sep 2012 22:57:21 +0000 (23:57 +0100)]
Core: Introduce LIBUSBX_API_VERSION macro
* This macro can be used to detect if the version of libusbx being
compiled against has a specific API feature, as well as to detect
whether compilation occurs against libusb or libusbx.
Hans de Goede [Sat, 15 Sep 2012 10:31:00 +0000 (11:31 +0100)]
Core: Make libusb_error_name also handle transfer status codes
Note that for the code 0 which means success resp. completed we have an
overlap in the codes. This is not a problem since normally one would not
call libusb_error_name on success / normal completion.
Ludovic Rousseau [Sat, 15 Sep 2012 08:18:50 +0000 (10:18 +0200)]
Samples: Fix compiler warnings in fxload
ezusb.c: In function "ezusb_cpucs"
ezusb.c:163: warning: initialization discards qualifiers from pointer target type
ezusb.c: At top level:
ezusb.c:193: warning: no previous prototype for "parse_ihex"
ezusb.c:340: warning: no previous prototype for "parse_bin"
ezusb.c:377: warning: no previous prototype for "parse_iic"
ezusb.c: In function "ram_poke":
ezusb.c:451: warning: enumeration value "_undef" not handled in switch
ezusb.c:491: warning: passing argument 2 of "ezusb_write" discards qualifiers from pointer target type
Pete Batard [Wed, 5 Sep 2012 23:47:08 +0000 (00:47 +0100)]
Core: Update libusb.h header in accordance with the latest USB specs
* IMPORTANT: This update fixes a typo in the API where MaxPower was being
used instead of bMaxPower, with the latter being what is actually in
the specs.
* As a result, applications that were using MaxPower need to be updated
for bMaxPower.
* If you must maintain compatibility with libusb or older versions of
libusbx, you may also want to either use a #define or copy/paste
struct libusb_config_descriptor from libusb.h under a new name, and
then use a cast on calls that require it. For more info, see the
1.0.13 release notes in the NEWS file.
* Also update copyright notice
Ludovic Rousseau [Thu, 13 Sep 2012 13:50:43 +0000 (15:50 +0200)]
Samples: Display VID:PID of the tested device in xusb
* Also amend the wording of the "no option" comment.
* Closes #42
Pete Batard [Thu, 13 Sep 2012 23:10:57 +0000 (00:10 +0100)]
Windows: Switch to ALLOW_PARTIAL_READS pipe policy enabled by default
* This avoids an issue when libusbK is used for bulk transfers, which
is most likely due to a libusbK bug
* See https://sourceforge.net/mailarchive/message.php?msg_id=
29736015
Pete Batard [Tue, 11 Sep 2012 00:01:07 +0000 (01:01 +0100)]
Samples: Add fxload sample for Cypress EZ-USB chips
* This program was modified from the original fxload at:
http://linux-hotplug.sourceforge.net to add libusbx
as well as non HEX images support.
* Only supports RAM upload for now, with EEPROM and FX3
support to be added at a later stage.
Hans de Goede [Wed, 12 Sep 2012 01:03:47 +0000 (02:03 +0100)]
All: Avoid polluting errors reported on device disconnect
* Makes libusb_cancel_transfer not log an error when the cancel fails
with LIBUSB_ERROR_NO_DEVICE, so that apps can properly clean things
up on device disconnect without flooding the console with these errors.
* Also, some devices (Cypress FX) may switch VID:PID on the fly during
firmware upload => reduce severity of the Windows message when that happens.
Pete Batard [Mon, 10 Sep 2012 23:17:39 +0000 (00:17 +0100)]
Doc: Update logging documentation regarding stderr usage
Pete Batard [Wed, 5 Sep 2012 21:51:19 +0000 (22:51 +0100)]
Windows: Fix handling of composite devices
* Pass missing sub_api parameter to set_composite_interface() and
composite_submit_control_transfer()
* Remove api_flags attribute, that cannot apply for multiple interfaces
* Also simplifies the internal ENUM_DEBUG mode
* Also move polluting info logging message to debug
Pete Batard [Mon, 3 Sep 2012 19:43:18 +0000 (20:43 +0100)]
Samples: xusb improvements
* update and fix usage details
* make topology and speed printout optional (option -i)
* remove unneeded option -g
Pete Batard [Sun, 26 Aug 2012 23:16:00 +0000 (00:16 +0100)]
Windows: Suppress unwanted error message on filter driver
* Interface access error message was unconditional, even if the
filter driver was found later on.
Hans de Goede [Wed, 22 Aug 2012 10:47:00 +0000 (11:47 +0100)]
Linux: Return ERROR_NOT_FOUND in detach-kernel-driver if usbfs is already bound
* Currently applications for devices which only are accessed from userspace
can use claim / release interface to make sure they don't get in each others
way.
* The same however does not work for applications which first need to detach
a "native" / in kernel driver, as this detach will not only detach native
drivers but also the usbfs driver, thus stealing the device from another
userspace / libusbx app.
* This patch fixes libusb_detach_kernel_driver to only detach "real" kernel
drivers and not the special usbfs driver used for userspace access to
USB devices. If the usbfs driver is found LIBUSB_ERROR_NOT_FOUND will be
returned to indicate no driver was detached.
Hans de Goede [Wed, 22 Aug 2012 10:47:00 +0000 (11:47 +0100)]
Linux: Avoid unnecessary splitting of bulk transfers
* With the latest kernels it is no longer needed to always split large bulk
transfers into multiple urbs. This patch takes advantage of this by not
splitting when not necessary. Note that the non-split code path is in essence
using the old split code path with an urb count which is always 1.
* This leads to more sane handling of large transfers with recent kernels,
although our splitting code is well tested, not splitting at all still is
a lot better :)
* When used with a recent kernel, this also fixes the problems, on XHCI attached
devices, when a large bulk-in transfer ends with a short read in an urb other
then the last urb.
* For more on this see: http://marc.info/?l=linux-usb&m=
133797554910355
Hans de Goede [Wed, 22 Aug 2012 10:47:00 +0000 (11:47 +0100)]
Linux: Add support for the new get_capabilities ioctl
* There were a few (new) usbdevfs capabilities which libusbx could not
discover in any other way then checking the kernel version.
* However, this presents the following problems:
1) It is just not very pretty
2) Given the tendency of enterprise distros to backport stuff it is not
reliable
3) Some of these features turn out to not work with certain host controllers,
making depending on them based on the kernel version not a good idea
* Therefore a new USBDEVFS_GET_CAPABILITIES ioctl has been added to the kernel
to offer a better way to find out a device's capabilities (technically
the capabilities of the host controller to which the device is attached,
but that does not matter).
Peter Stuge [Wed, 22 Aug 2012 08:32:10 +0000 (01:32 -0700)]
Core: Handle >= 1 second transfer timeout in libusb_submit_transfer()
* Comparisons between tv_nsec and 1 sec should be >= rather than >,
as we can end up in situations where tv_nsec is exactly
1000000000,
which calls such as timerfd_create() do not accept.
* Issue reported by Sebastian K. See:
https://sourceforge.net/mailarchive/message.php?msg_id=
29706972
Pete Batard [Wed, 22 Aug 2012 20:42:21 +0000 (21:42 +0100)]
Misc: Update and shorten various libusbx URLs
Nicholas Corgan [Mon, 20 Aug 2012 20:32:24 +0000 (13:32 -0700)]
Windows: Add support for 2nd gen Renesas USB 3.0 controllers
* Driver version 3.0.20.0 for uPD720201 & uPD720202 uses RUSB3HUB
* Closes #40
Pete Batard [Sun, 19 Aug 2012 22:40:42 +0000 (23:40 +0100)]
Windows: Add libusbk.sys & libusb0.sys driver support
* Both libusbk and libusb0.sys rely on libusbk.dll being
installed to provides a WinUSB-like API for driver access.
* In case libusbk.dll is not present, fall back to WinUSB.
* Closes #11
* Closes #12
Anthony Clay, ZarthCode LLC [Sun, 19 Aug 2012 19:19:40 +0000 (14:19 -0500)]
Windows: Fix C4005 warning under VS2012 for inline.
* Changed inline macro to not fire when using Visual Studio/C++,
which attempts to redefine the macro - resulting in a C4005 warning.
Pete Batard [Sun, 12 Aug 2012 21:57:10 +0000 (22:57 +0100)]
Samples: Make target mandatory with -b option in xusb
Pete Batard [Sun, 12 Aug 2012 21:37:02 +0000 (22:37 +0100)]
Core: Improve instrumentation of timerfd_settime failures
* Report errno as well as itimerspec data
* Also reuse the timeout variable set to &transfer->timeout
Pete Batard [Tue, 7 Aug 2012 12:36:16 +0000 (13:36 +0100)]
Core: Fix a Clang warning in io.c
* Using sizeof() in the UNUSED() macro didn't silence all
unused variable warnings.
* Also fix an "unused ctx" warning when ENABLE_DEBUG_LOGGING is on
* Also improve debug output on libusb_open() failure
Matthias Bolte [Sat, 28 Jul 2012 19:24:31 +0000 (21:24 +0200)]
Windows: Add workaround for Intel USB 3.0 root hubs
* Intel USB 3.0 root hubs are similar to the Nec/Renesas USB 3.0 root
hubs as they aren't listed under "USB" either but under "IUSB3".
* Extend the existing workaround for Nec/Renesas USB 3.0 root hubs to
handle the Intel ones as well.
* Closes #39
Pete Batard [Tue, 10 Jul 2012 00:59:45 +0000 (01:59 +0100)]
Core: Fix unconditional disarming of timerfd
* Existing code appears disarms the timerfd always, which cancels
pending timeouts as soon as one packet completes.
* This fix moves the disarming of the timerfd to
arm_timerfd_for_next_timeout(), where it is now done conditionally.
It also avoids calling disarm outside of the above call.
* This patch also ensures that all handling of the timerfd is done
under the flying transfers lock.
* Issue reported by Hans de Goede. For more info, see:
https://sourceforge.net/mailarchive/message.php?msg_id=
29442693
Orin Eman [Fri, 3 Aug 2012 13:21:45 +0000 (14:21 +0100)]
Core: NULL list pointers on deletion
* This aims at highlighting unwanted behaviours on list operations,
and facilitate early detection of potential bugs.
* This also requires a fix in threads_windows.c
* See http://sourceforge.net/mailarchive/message.php?msg_id=
29626351
Pete Batard [Wed, 1 Aug 2012 16:43:33 +0000 (17:43 +0100)]
Misc: Add a readme for git user
* Suggested by Yves Arrouye:
http://sourceforge.net/mailarchive/message.php?msg_id=
29577839
Pete Batard [Wed, 18 Jul 2012 17:25:11 +0000 (18:25 +0100)]
Windows: Set device number for root hubs to 1
* Other platforms (Linux, OS-X) appear to use 1 => follow suit.
* For non root hub devices, we simply increment the USB device address.
* Collisions with device address 0 are not expected, but we add
an assertion for just in case.
Pete Batard [Tue, 17 Jul 2012 16:36:13 +0000 (17:36 +0100)]
Windows: Fix overflow when handling HID or composite devices
* When libusb_get_device_list() is called mutliple times, the HID device
path was unconditionally duplicated in the list of device's interfaces.
* Because array boundaries were not checked, this caused overflow and crash.
* This patch adds an out of bound check and also ensures that duplication
of data, for HID and composite, does not occur
* It also renames the private composite_api_flags to api_flags, as well as
reorganizes the private attributes
* Bug report and part of the fix provided by Toby Gray
Simon Haggett [Tue, 10 Jul 2012 15:07:45 +0000 (16:07 +0100)]
Windows: usbi_cond_destroy() should free handles created by usbi_cond_intwait().
* Without this change every call to usbi_cond_destroy() leaks an event handle.
Davidlohr Bueso [Wed, 11 Jul 2012 12:53:00 +0000 (13:53 +0100)]
All: Replace malloc+memset with calloc
Pete Batard [Mon, 2 Jul 2012 22:39:19 +0000 (23:39 +0100)]
Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflicts
* The LOG_LEVEL_ enums, that were moved to the public API
in
933a319469bcccc962031c989e39d9d1f44f2885 may conflict
with applications/headers that also define their own
LOG_LEVEL_ values internally.
* As a matter of fact, as per Trac #31, this produces a
conflict with libusb-compat, as it defines its own levels.
Pete Batard [Thu, 28 Jun 2012 21:49:47 +0000 (22:49 +0100)]
Misc: Fix more Clang warnings in core and darwin
* http://sourceforge.net/mailarchive/message.php?msg_id=
29418038
* core.c:700:4: warning: Function call argument is an uninitialized value
* darwin_usb.c:1713:11: warning: Access to field 'cfSource' results in a
dereference of a null pointer (loaded from variable 'hpriv')
* sync.c/dpfp.c/dpfp_threaded.c: warning: Result of 'malloc' is converted
to a pointer of type 'unsigned char', which is incompatible with sizeof
operand type
Pete Batard [Mon, 25 Jun 2012 18:13:42 +0000 (19:13 +0100)]
Windows: Address MSVC Level 4 & WDK's OACR/Prefast warnings
* The library is now compiled with warning level 4 for VS2010
* Move silencing of 4200, 28125 and 28719 to msvc/config.h
* Add fixes in core to silence unused variables warnings
* Ensure that spinlock is always set interlocked in poll_windows
* Add missing check for calloc return value
* Fix data assignation in conditionals warnings
* Fix an OACR/Prefast error related to the use of strncpy in xusb.c
* Also fixes whitespace inconsistencies in core
* Issues reported by Orin Eman and Xiaofan Chen. See:
https://sourceforge.net/mailarchive/message.php?msg_id=
29412656
Xiaofan Chen [Sun, 17 Jun 2012 12:46:40 +0000 (20:46 +0800)]
Windows: Some versions of dlltool require a library name
* Even though the library name is optional as specified by Microsoft,
some recent versions of libtool require one in libusb-1.0.def.
* Reference thread in MinGW-w64 mailing list.
http://comments.gmane.org/gmane.comp.gnu.mingw.w64.general/5141
Pete Batard [Thu, 21 Jun 2012 19:17:09 +0000 (20:17 +0100)]
Windows: Fix warnings reported by the Intel Compiler
* windows_usb.c(161): warning #181: argument is incompatible
with corresponding format string conversion
* windows_usb.c(2124): warning #111: statement is unreachable
usbi_dbg("ERROR: broken timer thread");
* multiple: warning #188: enumerated type mixed with another
* Issues reported by Orin Eman
Pete Batard [Fri, 15 Jun 2012 14:14:48 +0000 (15:14 +0100)]
libusbx-1.0.12
Xiaofan Chen [Thu, 14 Jun 2012 11:42:02 +0000 (12:42 +0100)]
Samples: Remove USB version for speed designations in xusb
Pete Batard [Wed, 13 Jun 2012 12:38:46 +0000 (13:38 +0100)]
Windows: Fix erroneous pointer array allocation reported by Clang
* Result of 'calloc' is converted to a pointer of type 'unsigned char *',
which is incompatible with sizeof operand type 'PUSB_CONFIGURATION_DESCRIPTOR'
* priv->config_descriptor is indeed an array of pointers, with each descriptor
allocated, rather than a sequential list of fixed descriptor.
Pete Batard [Wed, 13 Jun 2012 12:33:00 +0000 (13:33 +0100)]
Core: Fix Clang warnings
core.c:
* Result of 'malloc' is converted to a pointer of type 'struct libusb_device *',
which is incompatible with sizeof operand type 'void *'
* Memory is never released; potential leak of memory pointed to by 'devs'
* Assigned value is garbage or undefined (due to potentially empty and
uninitialized device list)
descriptor.c:
* Function call argument is an uninitialized value
io.c:
* Call to 'malloc' has an allocation size of 0 bytes
* Branch condition evaluates to a garbage value (due to get_next_timeout
returning a negative error code instead of zero on error)
Pete Batard [Mon, 11 Jun 2012 13:03:57 +0000 (14:03 +0100)]
libusbx 1.0.12-rc1
Pete Batard [Mon, 11 Jun 2012 13:12:56 +0000 (14:12 +0100)]
Autotools: add libusb-1.0.def and libusb_nano.h as dependencies
* Also add version_nano.h to EXTRA_DIST as it is not added to the
dist archive by default
Pete Batard [Fri, 8 Jun 2012 22:31:56 +0000 (23:31 +0100)]
Windows: Enable MinGW and MSVC DLL interchangeability
* Because we use the WINAPI calling convention, the def file MUST have the @n
aliases. There is no way around this as MinGW's .o use decoration always
for __stdcall, which can't be turned off.
* dlltool must therefore be invoked to create a proper import lib from the .def,
using the --kill-at option.
* To do that, a CREATE_IMPORT_LIB autotools variable is introduced.
* Note: the .def file is currently maintained manually.
Pete Batard [Thu, 7 Jun 2012 18:27:43 +0000 (19:27 +0100)]
All: Prevent memory leaks on realloc failures
* p = realloc(p, new_size) does not free the original buffer in case of
a realloc failure.
* reallocf() can be used to do so, but is not available on all platforms.
* This patch introduces usbi_reallocf() in libusbi.h and use that instead of realloc
* Issue and original patch submitted by Moritz Lipp (trac #27)
Pete Batard [Thu, 7 Jun 2012 10:55:30 +0000 (11:55 +0100)]
Windows: Fix possible crash when using longjmp and gcc 4.6
* With gcc-4.6 the option -fomit-frame-pointer is turned on per default
even for the win32 target. This results in segfaults for any application
using setjmp/longjmp and MSVCRT.dll on WinXP.
See http://gcc.gnu.org/ml/gcc/2011-10/msg00351.html
* Issue reported by Lars Kanis
Pete Batard [Wed, 6 Jun 2012 12:49:41 +0000 (13:49 +0100)]
Core: Display libusbx version in libusb_init's debug output
Lars Wirzenius [Wed, 6 Jun 2012 16:34:04 +0000 (17:34 +0100)]
Autotools: Fix autogen.sh behavior when libtool is not found
* Fix naked "exit", which no exit code, to prevent a build failure
from being noticed automatically if a build dependency is lacking.
* Also printed error message to stderr rather than stdout.
Pete Batard [Wed, 6 Jun 2012 09:53:43 +0000 (10:53 +0100)]
Linux: Fix a major regression in threads_posix.c
* On some Linux platforms, libusbx compilation breaks with:
error: implicit declaration of function ‘pthread_mutexattr_settype’
* This regression, introduced in
463dda06db5da5de0eab32820c7af60605625afe,
is due to pthread.h needing __USE_UNIX98, which is tied to _XOPEN_SOURCE
or _GNU_SOURCE being correctly defined, and which the inclusion of
<unistd.h> before the _XOPEN_SOURCE override modified
* As _GNU_LINUX ensures the definition of __USE_UNIX98 and we require it
for syscalls, we now only define _GNU_SOURCE for Linux.
Pete Batard [Tue, 5 Jun 2012 16:29:46 +0000 (17:29 +0100)]
Autotools: Fix versioning regression in configure.ac
* Because of missing [], "LIBUSB_MICROLIBUSB_RC" was being displayed
in lieu of version number
* Regression introduced with
c9d41fe5f0324d969f758f42843e1fd05859f438
Pete Batard [Thu, 31 May 2012 17:31:34 +0000 (18:31 +0100)]
Core: Add toggleable debug logging
* Also fix a missing space in debug log messages introduced
with the previous timestamp logging update