commit 5bbbfc98bd309ab9425a6fb96b77bde9a5b244e6
Author: Pete Batard <pete@akeo.ie> Date: Sat Jan 25 22:35:16 2014 +0000 libusbx 1.0.18 *FINAL RELEASE* Continuation of this project is now ensured through libusb: https://github.com/libusb/libusb.git For more info, see http://libusb.info commit fc458425b6dd6258e562e44c22978ab22412ff0a Author: xantares <xantares09@hotmail.com> Date: Fri Jan 24 09:07:11 2014 +0000 Windows: Fix MinGW parallel build * Closes #168 commit d0db9a49fb1d2a264a75b0cd8888b76a09101766 Author: Sean McBride <sean@rogue-research.com> Date: Tue Jan 21 11:20:20 2014 -0500 Darwin: Fix Xcode warning in 'struct timeval' initialization commit 2adf2c7c13cc7fd525059f7a5cc8cd19d0179c86 Author: Pete Batard <pete@akeo.ie> Date: Wed Jan 8 20:31:04 2014 +0000 libusbx 1.0.18-rc1 commit 85e118aca6425108a408c3ce8b55a8d44fcef73c Author: Pete Batard <pete@akeo.ie> Date: Wed Jan 8 19:56:12 2014 +0000 Windows: Fix a MinGW compilation issue * Some MinGW platforms may not have FACILITY_SETUPAPI defined * Issue introduced with 8b46e1c088167eb86b1712765896e2f17d70d148 commit 0500232303fe706dbe538290a49869f1dadf90af Author: Matthias Bolte <matthias.bolte@googlemail.com> Date: Mon Oct 14 19:05:12 2013 +0200 Darwin: Fix format of 64-bit sessionIDs in log messages * The sessionID value is 64-bit, so print it as such. * Closes #153 commit 314f4ff998f6ba63607ce3be6cd7193a39cd1f78 Author: Bei Zhang <ikarienator@gmail.com> Date: Fri Aug 23 01:10:35 2013 -0700 Darwin: Fix a SIGFPE * GetPipeProperties() may fail when the device is unplugged if DeviceVersion is not greater than 320. * In this case maxPacketSize will be zero and the integer division will throw a EXC_ARITHMETIC signal. * Closes #136 commit b1bbea6f4f5cadc8ba2f48ae077f0c4ac339c3cc Author: Francisco Facioni <fran6co@gmail.com> Date: Fri Jun 14 13:03:54 2013 -0300 Darwin: Return error code in darwin_error_str() on unknown error * Closes #117 commit 8b46e1c088167eb86b1712765896e2f17d70d148 Author: Pete Batard <pete@akeo.ie> Date: Mon Dec 30 21:32:28 2013 +0000 Windows: Add SetupAPI error handling * http://msdn.microsoft.com/en-us/library/windows/hardware/ff545011.aspx states that SetupAPI errors must be be converted before passing it to FormatMessage(). * Use our own implementation of HRESULT_FROM_SETUPAPI to avoid defining a new function call. * Issue and original fix suggested by Matthias Bolte * Closes #166 commit 28424b945cc5abed182f83ab3fc70676986d7cf3 Author: Moritz Fischer <moritz.fischer@ettus.com> Date: Thu Nov 7 08:56:31 2013 +0100 Linux: Remove trailing whitespace * Closes #157 commit 7e3de5de095a493accc77081fb384be8e9144250 Author: Kuangye Guo <kuangye@ciinow.com> Date: Mon Oct 21 18:36:15 2013 -0700 Android: Add support for Linux/Android platforms * Closes #154 commit 650e22508f6d595d73d565423cb06b14049bd3af Author: Andrew Fernandes <andrew@fernandes.org> Date: Tue Aug 20 12:19:26 2013 -0400 Android: Build for all Android architectures * Don't limit support to ARM only (adds MIPS support) * Also add a workaround for a MIPS NDK linker bug * Also add a gitignore entry required to run bootstrap.sh on OS X * Closes #134 commit 805cc3ec40b5b6314e8cef8fb8cd9f8d4e95f293 Author: Joshua Blake <joshblake@gmail.com> Date: Sun Dec 8 22:58:17 2013 -0500 Windows: Add Visual Studio 2013 solution files * Also update gitignore * Closes #162 create mode 100644 msvc/fxload_2013.vcxproj create mode 100644 msvc/getopt_2013.vcxproj create mode 100644 msvc/hotplugtest_2013.vcxproj create mode 100644 msvc/libusb_dll_2013.vcxproj create mode 100644 msvc/libusb_static_2013.vcxproj create mode 100644 msvc/libusbx_2013.sln create mode 100644 msvc/listdevs_2013.vcxproj create mode 100644 msvc/stress_2013.vcxproj create mode 100644 msvc/xusb_2013.vcxproj commit 30747cee3f6d7dc4a98490c24fc9b8536ae79e51 Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Fri Dec 6 16:56:16 2013 +0100 core: fix Doxygen warning libusbx/libusb/libusb.h:153: warning: no matching file member found for libusb_cpu_to_le16()Possible candidates: static uint16_t libusb_cpu_to_le16(const uint16_t x) Thanks to Serhat Sevki Dincer for the bug report http://sourceforge.net/mailarchive/message.php?msg_id=31719691 commit 68bd52920ce6043678f6d19d1f221930e7a214d5 Author: Pete Batard <pete@akeo.ie> Date: Wed Nov 27 22:02:55 2013 +0000 Windows: Fix a crash when HID transfers return no data * Issue reported by Surmakyynis * Closes #160 commit 850dc391cfc6e3f7e8cf917f8baf646ae7ca83a1 Author: Hans de Goede <hdegoede@redhat.com> Date: Tue Oct 15 16:03:05 2013 +0200 core: Make LIBUSB_DEBUG environment variable also work from libusb_exit libusb_exit sets usbi_default_context to NULL, modify usbi_log_v so that it still honors the LIBUSB_DEBUG environment variable in this case. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 15ee9598454f0c3b6221f45d36c38fb474af74df Author: Hans de Goede <hdegoede@redhat.com> Date: Tue Oct 15 15:30:02 2013 +0200 hotplug: Fix usb_device memleak with hotunplug events pending on libusb_exit Closes #150 Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 359a273b36d810e0fda4117a3131116350db822b Author: Hans de Goede <hdegoede@redhat.com> Date: Tue Oct 15 15:15:31 2013 +0200 io: Ensure all pending events are consumed in one libusb_handle_events call Before this patch if ie multiple hot-plug events were pending, multiple handle_events calls would be necessary to handle them all, this patch changes handle_events so that the poll is re-done to check for more events if there was activity on any of the special fds. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 7b62a0a171ac0141a3d12237ab496c49cccd79df Author: Omri Iluz <omri@iluz.net> Date: Mon Oct 7 04:09:12 2013 -0700 Windows: Add support for VIA VL805 USB 3.0 Host Controllers * These controllers identify themselves as VUSB3HUB * Closes #152 commit 3d84bba0a7ff2d9e28f5aac43775f9a267caa4e8 Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Sun Oct 6 14:23:20 2013 +0200 examples: check value returned by ftell() Problem detected by the Coverity tool CID 1042546 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)3. negative_returns: "initial_pos" is passed to a parameter that cannot be negative. fseek(3) can't be called with a negative offset with SEEK_SET commit a9cd54f24d566062a461d27f615365f41a3d11e8 Author: Matthias Bolte <matthias.bolte@googlemail.com> Date: Tue Oct 1 14:10:48 2013 +0200 Windows: Avoid potential mismatch in transfer error reporting The default case in windows_transfer_callback() calls windows_error_str(0) which will convert the error code returned by GetLastError() to a string. This currently works because windows_transfer_callback() is either called with io_result set to NO_ERROR or io_result set to GetLastError(). If windows_transfer_callback() will ever be called with io_result set differently then the default case might report the wrong error message. Call windows_error_str(io_result) instead to avoid this. Closes #151 commit 16692c825e6f55548b28738dcf2f9b6157b9daf1 Author: Pete Batard <pete@akeo.ie> Date: Sun Sep 29 21:39:26 2013 +0100 examples: add an option to force a device request for WCID descriptors * Add option 'w' to force the use of a Device Request rather than an Interface Request when querying the WCID OS Extended Properties descriptor. * This is due to a WinUSB limitation where all Interface Requests have the wIndex set to the interface number. * This assumes that the WCID firmware answers both Device and Interface requests equally. commit 28d5514e61ca7f7459c200b187b8cc3ebeda9274 Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Sat Sep 28 13:14:17 2013 +0200 examples: fix warning ezusb.c: In function 'ezusb_load_ram': ezusb.c:719:6: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized] int ret; commit c4f2c353b9a1f6bc418dcd1d330d7c99084570d5 Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Sun Sep 22 21:29:50 2013 +0200 tests: set output_file to a valid value If fdopen(3) fails then ctx->output_file is NULL and should not be used in cleanup_test_output() called next. Problem detected by the Coverity tool CID 1042543 (#1 of 1): Dereference after null check (FORWARD_NULL)9. var_deref_model: Passing "ctx" to function "cleanup_test_output(libusbx_testlib_ctx *)", which dereferences null "ctx->output_file". commit c393574a0148a826e4be575c356b7b5724190c8c Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Sun Sep 22 21:25:00 2013 +0200 examples: check value returned by libusb_bulk_transfer() Problem detected by the Coverity tool CID 1042540 (#1 of 1): Unchecked return value (CHECKED_RETURN)1. check_return: Calling function "libusb_bulk_transfer(struct libusb_device_handle *, unsigned char, unsigned char *, int, int *, unsigned int)" without checking return value (as is done elsewhere 4 out of 5 times). commit d4dabfd14e50144c2935c4ef30202a8dd46b5ae6 Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Sun Sep 22 21:19:06 2013 +0200 examples: check the value returned by libusb_handle_events() Problem detected by the Coverity tool CID 1042539 (#1 of 1): Unchecked return value (CHECKED_RETURN)8. check_return: Calling function "libusb_handle_events(libusb_context *)" without checking return value (as is done elsewhere 6 out of 7 times). commit aa00030b78b4e46511c32c76c08ea031eacef8d1 Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Sun Sep 22 21:15:56 2013 +0200 examples: check the value returned by libusb_init() Problem detected by the Coverity tool CID 1042538 (#1 of 1): Unchecked return value (CHECKED_RETURN)4. check_return: Calling function "libusb_init(libusb_context **)" without checking return value (as is done elsewhere 11 out of 12 times). commit d09389be6f91f5e6a382a90f68916e8ee7444a60 Author: Karsten Koenig <remur@gmx.net> Date: Wed Sep 25 18:08:16 2013 -0400 linux: take newline into account for sysfs_get_active_config bConfigurationValue in sysfs can be 3 digits (1byte value) + 1 new line = 4 bytes In it's current form a bConfigurationValue of 128 will be detected as not null terminated due to the trailing newline, simple fix is to just extend the array size to 5 commit e2babf7ec295bde9d0b04fe1c325131dc6aacf51 Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Thu Sep 19 23:51:04 2013 +0200 examples: Fix a memory leak Close the image file before exiting the function Problem detected by the Coverity tool CID 1042549 (#2 of 3): Resource leak (RESOURCE_LEAK)9. leaked_storage: Variable "image" going out of scope leaks the storage it points to. commit 3c2e79cacfa286c7e990d97ac233b28db255a774 Author: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Thu Sep 19 23:46:14 2013 +0200 examples: Fix a memory leak Close the image file before exiting the function Problem detected by the Coverity tool CID 1042550 (#1 of 15): Resource leak (RESOURCE_LEAK)7. leaked_storage: Variable "image" going out of scope leaks the storage it points to. commit 8be2ef0fae96e830d7ab5bd74e0d51a663e46d24 Author: Hans de Goede <hdegoede@redhat.com> Date: Sun Sep 15 11:47:23 2013 +0200 Fix darwin compilation broken by the usbi_get_device_by_session_id changes Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 733ffffe44ad93bd81feddb0a8072510fd7a8321 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Sep 6 16:49:26 2013 +0200 Make usbi_get_device_by_session_id return a ref to the found device Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 4ffa16f8ef395dbbc48ae0fdd933d296446a9d91 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Sep 6 16:45:10 2013 +0200 openbsd: Fix a memleak discovered_devs_append takes a reference to the past in dev, so we must release our own reference. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit d758af27bb4a75d242a230cea39f952d16d07ee3 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Sep 6 16:40:51 2013 +0200 openbsd: Fix usbi_sanitize_device error handling If usbi_sanitize_device fails we need to continue from the beginning of the loop, rather then going on with the device we've just free-ed. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 5f366718c468231a4b233e437a8b3854c72f3310 Author: Gustavo Zacarias <gustavo@zacarias.com.ar> Date: Tue Sep 3 10:24:04 2013 -0300 configure.ac: uclinux is also linux When the tuple contains uclinux rather than just linux (nommu flat targets) configure will fail with an unknown operating system. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar> Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 0c3d17c9b1c96afe6889ae4595abb22072fc1c0d Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Sep 6 11:20:53 2013 +0200 Release 1.0.17 Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit def6a8f879e77bbf1606e21f8dc8d7335da9d381 Author: Xiaofan Chen <xiaofanc@gmail.com> Date: Mon Sep 2 11:35:40 2013 +0100 Windows: Address an VS2012/x64 warning in hotplug.c ..\libusb\hotplug.c(255): warning C4244: '=' : conversion from 'ssize_t' to 'int', possible loss of data commit 1c1ec3f27c4a3f71b3fec0c1aea0e6514d67fff5 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Aug 30 16:50:12 2013 +0200 Nathan is a maintainer now, so add him to the README Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit ce1f150d12d670d7c4c9d26a526bbd3c394843aa Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Aug 30 16:49:32 2013 +0200 Remove unused THANKS file Signed-off-by: Hans de Goede <hdegoede@redhat.com> delete mode 100644 THANKS commit 65e1a90a7fb4da17abbd3e6c3c9a13c8cb2c420e Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Aug 30 16:44:45 2013 +0200 Makefile.am: Add Xcode dir to EXTRA_DIST Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 31b180dbdc5fea55df9a6ac051944516ed3d1b7f Author: Toby Gray <toby.gray@realvnc.com> Date: Fri Aug 30 14:42:34 2013 +0200 Android: Add android build files to source tarball Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 6512943087bd7ef1732b0a98e856829abb175f53 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Aug 28 10:17:53 2013 +0200 Release 1.0.17-rc1 Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 52cdd1a5c91ea64908885bb4a83634cb03257728 Author: Nathan Hjelm <hjelmn@me.com> Date: Mon Aug 26 20:40:52 2013 -0600 darwin: return libusb error codes instead of kernel error codes and fix a bug introduced in the last commit. commit 7b14df40b00d82adeae99367f64076823c23684f Author: Nathan Hjelm <hjelmn@me.com> Date: Mon Aug 26 20:12:23 2013 -0600 darwin: clean up some code. remove a clang warning The check for NULL != cached_device was unnecessary and caused clang's static analysis to print out a warning. commit 0837c479dc197b27884d717bf4ddc31cae65afd9 Author: Toby Gray <toby.gray@realvnc.com> Date: Wed Aug 21 16:27:03 2013 +0200 Android: Add further documentation to Android README file Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 3b4a7c9d93b55be5e2c8edb10daa38356c84d8c3 Author: Martin Pieuchot <mpi@openbsd.org> Date: Tue Jul 16 11:32:23 2013 +0200 OpenBSD: Add basic support for non ugen(4) devices using usb(4) It is now possible to have a read access and submit control transfers to all USB devices using libusb, please note that controllers and hubs also appear as devices. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit eb4e7bee4488cefcf13929d9c4fe784650fef7c7 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Aug 21 16:18:39 2013 +0200 openbsd: Split openbsd backend into separate openbsd and netbsd backends Note the new netbsd_usb.c is an unmodified copy of openbsd_usb.c with s/obsd/netbsd done on it. The reason for this split is that the openbsd developers have been working on various improvements for their userspace usb support, and adding support for those means breaking netbsd support, by giving netbsd its own backend we can add support for the openbsd improvements without breaking netbsd support. Signed-off-by: Hans de Goede <hdegoede@redhat.com> create mode 100644 libusb/os/netbsd_usb.c commit c089900c486e94b067e4d30ef9047a80cbb6d689 Author: Paul Fertser <fercerpav@gmail.com> Date: Mon Jul 1 21:07:24 2013 +0400 Clarify alignment requirements for the control transfer buffer Since the buffer pointer will later be casted to ``struct libusb_control_setup *'', it should point to memory aligned to at least 2 bytes boundary as that's the strictest requirement of the struct fields. Also, use a (void *) casting trick to convince the compiler the cast is safe, to fix warnings such as: /usr/local/include/libusb-1.0/libusb.h: In function 'libusb_control_transfer_get_setup': /usr/local/include/libusb-1.0/libusb.h:1435:9: error: cast increases required alignment of target type [-Werror=cast-align] /usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_setup': /usr/local/include/libusb-1.0/libusb.h:1464:39: error: cast increases required alignment of target type [-Werror=cast-align] /usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_transfer': /usr/local/include/libusb-1.0/libusb.h:1509:39: error: cast increases required alignment of target type [-Werror=cast-align] cc1: all warnings being treated as errors This actually can lead to failure to build from the sources for certain projects which use -Werror=cast-align on ARM. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 6732582bb17662aa02a913008be899ef9ace5870 Author: Chris Dickens <christopher.a.dickens@gmail.com> Date: Thu Jun 27 09:14:15 2013 -0700 linux: Handle device disconnection early when possible If a device is open, the device's fd will trigger a POLLERR condition once it is removed. Sometimes this can occur well before the udev monitor sends the remove event. This can also be caught early if the device is not currently open but an attempt to open it is made. In both situations, this can be caught early and processed so that the device does not continue to show up in the device list after it has been disconnected but before the udev monitor processes the event. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit a06eafdc528d5f3ea21a26c34ceaa13e09dfd4f3 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Aug 21 14:46:45 2013 +0200 hotplug: Document LIBUSB_HOTPLUG_ENUMERATE gotchas When libusb_hotplug_register_callback gets called with the LIBUSB_HOTPLUG_ENUMERATE flag, there may still be hotplug events pending in the hotplug pipe, waiting for dispatching from libusb_handle_events. This means that the user callback can be called twice for arrival of the same device, once from libusb_hotplug_register_callback, since the device is already part of the usb_devs list, and once from libusb_handle_events when it reads the event from the hotplug pipe. This could be fixed by adding a mechanism to pause hotplug handling, then drain the hotplug pipe (ie by calling libusb_handle_events from libusb_hotplug_register_callback), before iterating over the usb_devs list, and then un-pausing hotplug handling afterwards, doing this however requires a lot of hairy code, which will be prone to dead-locking. OTOH it is quite simple for user applications which care about this to detect this and ignore the 2nd call, so lets simply document this may happen and be done with it. Note that this is also the solution which ie libudev has choosen, there is no way with libudev to get a device-list + listen for device arrival / removal without running into the same problem. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 0fc304da83595da9830bf368f66312ffd793f10c Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Aug 21 14:30:51 2013 +0200 hotplug: Document that callbacks cannot unregister themselves when called from hotplug_register_callback Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit be76bef5b716d27b78fba120d3f9b815ed3380b9 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Aug 21 14:18:09 2013 +0200 hotplug: Don't call the user callback while holding various locks Calling user callbacks with locks held is a bad idea and should be avoided whenever possible. Before this patch this could lead ie to the following hang: 1) User calls libusb_hotplug_register_callback with the LIBUSB_HOTPLUG_ENUMERATE flag 2) libusb_hotplug_register_callback calls the user callback while holding the hotplug_cbs_lock 3) The callback calls a synchronous libusb function 4) The synchronous libusb function calls libusb_handle_events 5) There is an hotplug event waiting in the hotplug pipe and libusb_handle_events calls usbi_hotplug_match 6) usbi_hotplug_match tries to take the lock a 2nd time 7) hang / assert / abort (depending on the platform) Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit fad4a18c8a55947a9c4f1a427427b176e053a991 Author: Hans de Goede <hdegoede@redhat.com> Date: Tue Aug 20 15:18:59 2013 +0200 hotplug: Remove device from usb_devs before signalling its removal If we write the remove event to the pipe before doing the list_del, in theory another thread can process the event and unref the device before it has been removed from usb_devs. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 11335a2620a39a403b17a7809735712ec7a64a2c Author: Hans de Goede <hdegoede@redhat.com> Date: Tue Aug 20 14:41:36 2013 +0200 libusb: Fix usb_devs_lock mutex use after free in libusb_init error path Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit f0fb99aeb93f45d2846f8884a348e90438d13ef8 Author: Nathan Hjelm <hjelmn@cs.unm.edu> Date: Wed Aug 14 11:08:36 2013 -0600 linux/netlink: correct usage of fcntl Closes #130 commit 368d613a17a3d768a7f434b886a8299f13711f8d Author: Pete Batard <pete@akeo.ie> Date: Tue Aug 13 19:00:54 2013 +0100 Windows: Fix a cast warning when compiling for x64 in VS * Also fixes and closes #129 again commit d28ab4bf13eb101f35d3543a3b2c2ca51a98e19d Author: Pete Batard <pete@akeo.ie> Date: Mon Aug 12 22:04:39 2013 +0100 Windows: Fix VS2010 project files * Closes #129 commit c6321017903dbeb92a417d6d1128edc46dcb7100 Author: Toby Gray <toby.gray@realvnc.com> Date: Thu Aug 8 18:22:21 2013 +0100 Android: Add examples and stress tests create mode 100644 android/jni/examples.mk create mode 100644 android/jni/libusb.mk create mode 100644 android/jni/tests.mk commit 7bfbb8b331fc09d5ad64dbcbc6730f5d1d3c0933 Author: Toby Gray <toby.gray@realvnc.com> Date: Tue Jul 9 16:43:53 2013 +0100 Android: Add formal Android support * Also fix an issue with LIBUSB_LOG_LEVEL_NONE create mode 100644 android/README create mode 100644 android/config.h create mode 100644 android/jni/Android.mk create mode 100644 android/jni/Application.mk commit 9222a548bdea026c89057b65caf2832785ea702e Author: Toby Gray <toby.gray@realvnc.com> Date: Tue Jul 9 16:05:39 2013 +0100 Core: Add compile time option to use native OS logging facility * This change makes it easier to debug issues in UI applications which don't necessarily have a console connected to stderr. * Outputting to the debugger shouldn't occur in normal situations so this change has to be explicitly enabled by a build-time config flag. * Uses OutputDebugString() on Windows platforms or the syslog facility on other OSes, if available. * Also align the report of configure defaults to autotool's. commit b50a433c164996761344efb6c90594de7906fe56 Author: Nathan Hjelm <hjelmn@me.com> Date: Wed Aug 7 21:01:43 2013 -0600 linux: ensure the netlink socket is correctly opened with older Linux kernels It is possible for the extra socket flags (available from 2.6.27 on) to be defined but not available. Check for this case and set the flags correctly on the netlink socket. commit c848e5b72a1670a33eb84f210b951177a3de19e9 Author: Chris Dickens <christopher.a.dickens@gmail.com> Date: Tue Aug 6 13:16:16 2013 -0700 Core: Fix potential segfault caused by using freed memory When a transfer is submitted, the device is referenced in libusb_submit_transfer() and unreferenced in usbi_handle_transfer_completion(). This transfer could potentially be freed by any user callback, or is freed by libusb if LIBUSB_TRANSFER_FREE_TRANSFER is set in the flags. The call to unreference the device uses this potentially freed memory. Reading the device handle beforehand will prevent this disaster. commit 69d88b7fef75aef4ab99b1086c5be84626aedceb Author: Simon Haggett <simon.haggett@realvnc.com> Date: Fri Jul 12 10:06:00 2013 +0100 Windows: Fix race between windows_clock_gettime_threaded() and windows_clock_gettime() * When the timer thread is created in windows_init(), it performs an initialisation phase in which it uses QueryPerformanceFrequency() to determine if there is a high resolution timer available, and sets hires_frequency and hires_ticks_to_ps appropriately. However, since windows_init() does not wait for this initialisation phase to complete, windows_clock_gettime() can be called before hires_frequency and hires_ticks_to_ps have been updated. This can result in windows_clock_gettime() temporarily returning real-time clock values even though the platform supports a monotonic clock. * See http://sourceforge.net/mailarchive/forum.php?thread_name=1373620013-3574-1-git-send-email-simon.haggett%40realvnc.com&forum_name=libusbx-devel commit b3562727e9cb75bf503c476452c9378c79385e71 Author: Simon Haggett <simon.haggett@realvnc.com> Date: Fri Jul 12 10:06:00 2013 +0100 WinCE: Fix race between wince_clock_gettime_threaded() and wince_clock_gettime() * When the timer thread is created in wince_init(), it performs an initialisation phase in which it uses QueryPerformanceFrequency() to determine if there is a high resolution timer available, and sets hires_frequency and hires_ticks_to_ps appropriately. However, since wince_init() does not wait for this initialisation phase to complete, wince_clock_gettime() can be called before hires_frequency and hires_ticks_to_ps have been updated. This can result in wince_clock_gettime() temporarily returning real-time clock values even though the platform supports a monotonic clock. * See http://sourceforge.net/mailarchive/forum.php?thread_name=1373619997-3535-1-git-send-email-simon.haggett%40realvnc.com&forum_name=libusbx-devel commit 388a9a88059cb5b5a8088788f5ccd6c3eec80f62 Author: Simon Haggett <simon.haggett@realvnc.com> Date: Thu Jul 11 17:27:00 2013 +0100 Windows: fd_to_winfd() shouldn't treat fd 0 as invalid * fd_to_winfd() currently returns INVALID_WINFD if fd is 0, but usbi_create_fd() can legally assign an fd number of 0 if poll_fd[0] is not already occupied. * Transfers which are assigned an fd number of 0 for their event handle are then unable to have their event handle retrieved later on. See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-PATCH-1-1-Windows-fd-to-winfd-shouldn-t-treat-fd-0-as-invalid-tt1535.html commit a3b92f8fe1953015322ed400570701943a59f3af Author: Sean McBride <sean@rogue-research.com> Date: Fri Oct 12 15:04:03 2012 -0400 README: Add OS X specific notes Xcode 4.3 do not provide autotools anymore. libusbx now provides a Xcode project to ease build Mac OS X. commit 7dad81fe6167c7dc903f88f3d1878a2f65b91710 Author: Chris Dickens <christopher.a.dickens@gmail.com> Date: Fri Aug 2 11:33:41 2013 +0200 Core: correctly check usbi_read() returned value For messages received on the hotplug pipe, the message was read via usbi_read() (ssize_t) and compared against the size of the message struct (size_t). usbi_read() returns -1 on an error condition, so some systems can cast the ssize_t to size_t for the comparison, making it equal to SIZE_MAX and causing the error check condition to incorrectly evaluate to false. commit fedc3631f88462d7dfa6af7fc1328b5675eea059 Author: Sean McBride <sean@rogue-research.com> Date: Fri Oct 12 17:31:45 2012 -0400 Core: defensive programming Defensively set return-by-reference value to -1 in error condition NB: The comments do not match the implementation. Comments: "[return] the index of the configuration matching a specific bConfigurationValue in the idx output parameter, or -1 if the config was not found" There is a code path where idx is never touched. Perhaps clients of the function are careful to only read idx if the return value is success, but also setting idx to -1 is much safer. commit b5acea3591ee713ec3392e8d3c8ba59e848d8641 Author: hjelmn <Nathan Hjelm hjelmn@cs.unm.edu> Date: Tue Jul 30 13:28:27 2013 -0600 darwin: fix clang warnings about explicit conversion There shouldn't be any problems with any supported version of OSX in converting a UInt64 to an unsigned long. They should be the same size but even if they are not the session should still be unique. commit 4cb9ae0c22c576298fb182868d765bcae6e1993a Author: Sean McBride <sean@rogue-research.com> Date: Fri Jul 26 14:11:53 2013 -0400 fixed link errors by adding missing files to Xcode project commit ce8da723b4e4c29268c0a15f010838f5a70c931a Author: Sean McBride <sean@rogue-research.com> Date: Fri Jul 26 14:13:45 2013 -0400 made some globals static to fix warnings commit ea6c827af035b279fd6bbbcc2e8093766ed57367 Author: Sean McBride <sean@rogue-research.com> Date: Fri Jul 26 14:13:40 2013 -0400 fixed some clang -Wdocumentation warnings from bad doxygen markup commit 4d198fe0cf7beac79ace20f12f8ddc0d84b10516 Author: Sean McBride <sean@rogue-research.com> Date: Fri Jul 26 14:13:03 2013 -0400 fixed compiler warning about possible uninitialized use by zero initializing commit 8f13c72409183c13a11044cbf70f15374262a870 Author: Sean McBride <sean@rogue-research.com> Date: Wed Oct 31 13:18:32 2012 -0400 make targets for examples depend on library target. Generate library named libusb-1.0.0.dylib not libusbx.dylib. Added several xcconfig files to make source control and documentation easier. Reorganised a few files' positions within the project. Disable strict aliasing since libusbx breaks strict aliasing rules anyway. Set project format as 3.1-compatible. Conflicts: Xcode/libusbx.xcodeproj/project.pbxproj create mode 100644 Xcode/common.xcconfig create mode 100644 Xcode/debug.xcconfig create mode 100644 Xcode/libusbx.xcconfig create mode 100644 Xcode/libusbx_debug.xcconfig create mode 100644 Xcode/libusbx_release.xcconfig create mode 100644 Xcode/release.xcconfig commit 059e648ab9aab8d09c5747844b921962887193b7 Author: Ludovic Rousseau <ludovic.rousseau@gmail.com> Date: Wed Oct 31 09:20:33 2012 +0100 Xcode: build for 32 and 64 bits commit bd57a42aba37704e7dc8eb5e8c787830df73ff86 Author: Ludovic Rousseau <ludovic.rousseau@gmail.com> Date: Fri Oct 26 09:44:16 2012 +0200 Xcode: remove implicit/default configuration commit a0d7a89c33367ffda54894925815eeb4179ea446 Author: Ludovic Rousseau <ludovic.rousseau@gmail.com> Date: Fri Oct 26 09:32:54 2012 +0200 Add minimal config.h for Xcode Xcode do not use ./configure so the config.h file needs to be generated by hand. This config.h is the minimal file for libusbx built using Xcode. create mode 100644 Xcode/config.h commit b11f8e08e01cf52dafd9bdf74476310bac77e0ac Author: Ludovic Rousseau <ludovic.rousseau@gmail.com> Date: Fri Oct 26 09:25:22 2012 +0200 Adapt Xcode project to the new paths commit 1640bf7f95a85fb0dcec0474f3ede269aeb7ce38 Author: Ludovic Rousseau <ludovic.rousseau@gmail.com> Date: Fri Oct 26 09:21:35 2012 +0200 Move Xcode project in Xcode/ directory This is to use Xcode special config.h file in a independent directory. The same is already done for MS Visual C with msvc/ directory. create mode 100644 Xcode/libusbx.xcodeproj/project.pbxproj delete mode 100644 libusbx.xcodeproj/project.pbxproj commit db59090457904f901cc7f3ab3541cdde28069041 Author: Ludovic Rousseau <ludovic.rousseau@gmail.com> Date: Fri Oct 12 23:30:26 2012 +0200 Xcode project create mode 100644 libusbx.xcodeproj/project.pbxproj commit 3107f30baddabf18039a4ca99c8a50b7f13f4de8 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Jul 19 10:52:18 2013 +0200 linux_netlink: Remove use of pthread_cancel Using pthread_cancel() presents the opportunity for deadlock, so use a control pipe to cause the event thread to gracefully exit. Inspired on the identical patch for linux_udev from Chris Dickens. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 9afce4282ecbb32e0cef9282d7f97f2353d7eca1 Author: Hans de Goede <hdegoede@redhat.com> Date: Tue Jul 30 16:56:54 2013 +0200 linux_netlink: close netlink socket on init error Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 6ac8cd3ef3400ae2f061c194d54c0020ccb01607 Author: Chris Dickens <christopher.a.dickens@gmail.com> Date: Sat Jul 20 13:01:41 2013 -0700 hotplug: Remove use of pthread_cancel from linux_udev Using pthread_cancel() presents the opportunity for deadlock, so use a control pipe to cause the event thread to gracefully exit. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit d8a33df7dda5ebfae0ffd6272183a546aa99547d Author: Hans de Goede <hdegoede@redhat.com> Date: Tue Jul 30 15:57:16 2013 +0200 linux: Use a separate lock to serialize start/stop vs hotplug events Using one lock for this is a bad idea, as we should not be holding any locks used by the hotplug thread when trying to stop otherwise the stop function may wait indefinetely in pthread_join, while the event-thread is waiting for the lock the caller of the stop function holds. Using 2 separate locks for this should fix this deadlock, which has been reported here: https://bugzilla.redhat.com/show_bug.cgi?id=985484 Many thanks to Chris Dickens for figuring out the cause of this deadlock! CC: Chris Dickens <christopher.a.dickens@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 242d49c636b390d64740b79953c68c2b28cae8ff Author: hjelmn <Nathan Hjelm hjelmn@cs.unm.edu> Date: Mon Jul 29 10:22:53 2013 -0600 work around Linux systems that don't provide SOCK_CLOEXEC or SOCK_NONBLOCK These options were added in 2.6.27 and are not available on all kernels that support netlink. Set these options using fcntl when SOCK_CLOEXEC and SOCK_NONBLOCK are not available. Closes #124. commit 252e193d9a910389baf9aa0736551f388c43e95c Author: hjelmn <Nathan Hjelm hjelmn@cs.unm.edu> Date: Mon Jul 29 10:11:33 2013 -0600 fix warnings in linux_get_device_address Warnings: os/linux_usbfs.c: In function 'linux_get_device_address': os/linux_usbfs.c:620: warning: comparison is always false due to limited range of data type os/linux_usbfs.c:624: warning: comparison is always false due to limited range of data type os/linux_usbfs.c:628: warning: comparison is always false due to limited range of data type os/linux_usbfs.c:628: warning: comparison is always false due to limited range of data type commit 67f0c1f100c3ab6b84fa026a47c00e0be147eb8f Author: hjelmn <Nathan Hjelm hjelmn@cs.unm.edu> Date: Mon Jul 29 10:10:56 2013 -0600 include stdlib.h for free and realloc in libusbi.h References #124. commit 872ff1704b79034af14cd09ac335bd97fe9be1ea Author: Nathan Hjelm <hjelmn@me.com> Date: Sat Jul 27 13:57:39 2013 -0600 Silence automake 1.14 warning The warning is: libusb/Makefile.am:57: warning: source file 'os/threads_windows.c' is in a subdirectory, libusb/Makefile.am:57: but option 'subdir-objects' is disabled automake: warning: possible forward-incompatibility. automake: At least a source file is in a subdirectory, but the 'subdir-objects' automake: automake option hasn't been enabled. For now, the corresponding output automake: object file(s) will be placed in the top-level directory. However, automake: this behaviour will change in future Automake versions: they will automake: unconditionally cause object files to be placed in the same subdirectory automake: of the corresponding sources. automake: You are advised to start using 'subdir-objects' option throughout your automake: project, to avoid future incompatibilities. Fixed by setting the subdir-objects option. Closes #125. commit 83021abc20102e45f0eab53a3bea92279259182a Author: Nathan Hjelm <hjelmn@me.com> Date: Sat Jul 27 12:35:51 2013 -0600 Add checks for headers needed by linux/netlink.h These headers are required by netlink.h. I am not sure how this worked at all. It certainly doesn't work with older versions of Linux 2.6. References #124. commit 707d500b9fea002f075cf30458a602f28dbd1348 Author: Nathan Hjelm <hjelmn@me.com> Date: Tue Jul 23 20:56:37 2013 -0600 keep a reference to the device for each active transfer and let the backend handle cancelling active transfers when a device is disconnected This commit should fix issues with active transfers when a device is disconnected. The backend is responsible for making sure the completion callbacks are made, not the hotplug code. This should fix a number of issues including duplicate callbacks and segmentation faults. References #124. commit 97958ba756b2f90aa9f65cc7674bc558768dde9f Author: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com> Date: Fri Jul 12 14:10:00 2013 +0100 hotplug: Pass explicit context to callbacks * Instead of passing NULL for the context to hotplug callbacks, if the context happens to be the default context, always pass the explicit context pointer. commit d1ed6c4d6729b7527f9d1f743242e6bcd7f49195 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jul 11 11:04:02 2013 +0200 Prepare for 1.0.16 final release Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit faa62417fb7996ea491e1401b4a6eca8d888648a Author: Hans de Goede <hdegoede@redhat.com> Date: Sat Jul 6 09:09:25 2013 +0200 Prepare for 1.0.16-rc3 release Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit ef59b06f4addfa9a5413b058cfb4f674df447411 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Jul 5 16:57:51 2013 +0200 Documentation: add an Using an event handling thread section Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 230b9a0105fd81dbeacec42715285651df3a3591 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Jul 5 16:17:45 2013 +0200 Documentation: explain the 2 main viable event handling approaches Stop pretending that having a separate event handling thread is a bad thing, specifically delete the "[this] option is not very nice either, but may be the nicest option available to you if the "proper" approach can not be applied to your application", which suggests that using poll integration into a main loop is the one and only "proper" approach. Instead clearly document there are 2 viable approaches, using a separate thread, or poll integration into a main loop. Also stop claiming that libusb does not use threads internally, as with the new hotplug support this is no longer true. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit ac41bfc0fdcf2229fbeb19cdf802cc6b551fd365 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jul 4 16:38:22 2013 +0200 hotplug: Wakeup libusb_handle_events on libusb_hotplug_deregister_callback This serves 2 purposes: 1) We use lazy free-ing of the callback structure, for it to be actually free-ed usbi_hotplug_match() needs to be called. This ensures this actually happens (rather then waiting for a hotplug event to arrive, and not freeing the callback as long as no such event arrives). 2) It causes libusb_handle_events to return to its caller on a call to libusb_hotplug_deregister_callback, which is very useful for apps which use a thread to do their apps (hotplug) event handling, otherwise that thread will hang when the app tries to stop until some event happens. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit f50592979811a00d52305ea02b420cb9cacc99b4 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jul 4 16:30:36 2013 +0200 hotplug: Give the usbi_hotplug_match* functions a context parameter So that the device parameter can be NULL, in combination with a 0 events parameter, to be used to force lazy deregistration. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit b4c18fac65a594502eec5edd2611d5953e7950f7 Author: Pete Batard <pete@akeo.ie> Date: Wed Jul 3 22:41:55 2013 +0100 Doc: update hotplug, topology and descriptor documentation * Also fix some typos * Closes #95 commit ea39a14d0afc255a47f380480d7f0fc925a0e7eb Author: Hans de Goede <hdegoede@redhat.com> Date: Mon Jul 1 13:00:43 2013 +0200 Prepare for 1.0.16-rc2 release Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 975c4fd6255a3ef9cc52ba0c9b5f94afec0ab7d2 Author: Tim Roberts <timr@probo.com> Date: Sun Jun 30 09:54:20 2013 +0200 Core: Use fputs(3) instead of fprintf(3) This is a micro-optimisation, but it should make the code easier to understand. commit 7b893cc7cee185c0bf771166ca61a05b32800556 Author: Pete Batard <pete@akeo.ie> Date: Sun Jun 30 00:32:10 2013 +0100 Core: Fix writing of log lines a single fprintf call * fb4c208c33788068bbca67bdd6d11127b5be5a26 broke cygwin compilation due to __GCC__ not being defined * The actual issue is that __GNUC__ rather than __GCC__ should have been used all along * Also fixes gettimeofday() usage for MinGW/Cygwin * Also increase log buffer size to 1K, fix a broken fprintf in core.c and sort whitespaces commit fb4c208c33788068bbca67bdd6d11127b5be5a26 Author: Toby Gray <toby.gray@realvnc.com> Date: Thu Jun 27 14:49:21 2013 +0100 Core: Make writing of log lines a single fprintf call. Prior to this change a single line of logging performing several fprintf. This change gets all the data for a line to be logged in a single fprintf call. This reduced the chances of writes from another thread getting intermixed with a log line. It also makes it easier to change where logs are output to in the future. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit e2c54d93b1fd89517b75e6761fad72f7c35532ad Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 27 09:33:28 2013 +0200 core: Always warn when there are leaked device refs on exit This check should done with hotplug capable backends too. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 004c7a7fabb1c1f1ded97c776291c4a645941d99 Author: Toby Gray <toby.gray@realvnc.com> Date: Wed Jun 26 16:26:39 2013 +0100 Core: Avoid passing uninitialised data down the hotplug pipe. Due to alignment requirements, libusb_hotplug_message might have some padding bytes. This change makes sure that these padding bytes are initialised. Valgrind no longer complains about passing uninitialised data to the write system call. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 83c9c3cb73bb9af710c6f8e068d0af8b7206df08 Author: Chris Dickens <christopher.a.dickens@gmail.com> Date: Tue Jun 25 14:45:07 2013 -0700 core.c: Initialize auto_detach_kernel_driver to 0 for new handle Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 17caf6d179c713c24d591acc0b475bf670cdfa7e Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Jun 26 17:13:44 2013 +0200 openbsd: Fix memleak in obsd_get_device_list() Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 163e2083e290eb878f4e38b17daf5998a7a29c47 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Jun 26 16:50:56 2013 +0200 core: Only do hotplug cleanup for hotplug capable backends Xiaofan encountered a crash while testing on openbsd. The main problem here is libusb_exit doing hotplug cleanup on a non hotplug capable backend. If the usb_devs list is non empty (*) at libusb_exit time with a non hotplug capable backend, then the hotplug cleanup code will unref the devices in the list. Assuming this is the last unref, then libusb_unref_device will call usbi_disconnect_device, which will try to take the usb_devs_lock, which is already hold by libusb_exit. Note that if this deadlock was not there, that we then also would have a double list_del issue. *) This should never happen, if it does either libusb or the app has a memleak, or the app still holds a reference to the device. The latter is an application bug, since device->ctx will be invalid after libusb_exit, so the application should not hold references after calling libusb_exit. In this case we have a memleak the libusb openbsd code causing the usb_devs list to be non empty. This will be fixed in another commit. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit c1bf7fbab0ed2b5606ff0d50cde2896d0ac2f4ff Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Jun 26 16:41:22 2013 +0200 WinCE: ref result of usbi_get_device_by_session_id() After the "WinCE: Fix device reference leak which caused crash on libusb_exit()" commit, the code always unref-s dev after adding it to discovered_devs. But if dev comes from usbi_get_device_by_session_id() it is a weak ref and as such should not be unreffed. Instead of re-adding comlicate ref tracking logic, this patch fixes this with a libusb_device_ref(dev) of dev comes from usbi_get_device_by_session_id(), turning the weak ref into a strong ref. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 43fbe3df02551c4ad9b5976fbd5acc6280e66829 Author: Toby Gray <toby.gray@realvnc.com> Date: Mon Jun 24 12:31:26 2013 +0100 WinCE: Fix device reference leak which caused crash on libusb_exit(). The Windows CE device allocation code has always had a bug where it would leak references to devices when they are allocated. This commit removes the reference leak. This leak was highlighted by the new hotplug code which now triggers a NULL pointer dereference if not all devices are unreferenced before libusb_exit is called. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 1b3c8272d6c9852977e87f4106a4669ebb25980b Author: Pete Batard <pete@akeo.ie> Date: Thu Jun 20 23:00:34 2013 +0100 Misc: Update AUTHORS file commit e2fe75ebab83d2fe8ee8ebc3ff13fef0132bff18 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 20 15:18:10 2013 +0200 Prepare for 1.0.16-rc1 release Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 061a807b9d94aca042f37c59b9ac4e73af421061 Author: Colin Walters <walters@verbum.org> Date: Thu May 30 13:34:57 2013 -0400 autogen.sh: Honor NOCONFIGURE=1 See http://people.gnome.org/~walters/docs/build-api.txt Hdg: I know this may seem unnecessary since we also have bootstrap.sh, but the Gnome people are doing continues build testing of Gnome + dependencies and having all autogen.sh scripts support NOCONFIGURE=1 makes live easier for them. Note that in return we get "free" continues build-testing and patches and / or a heads up when we break things. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 5b48dd2a64d7177e4bb2a530814bb377c772cc90 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 20 13:08:58 2013 +0200 sync.c: Remove code duplication Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit edcb3829a869f3d6781d5239de035fb12e3a95c9 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 20 12:52:25 2013 +0200 sync.c: Do not free an incompleted transfer Before this patch the code in sync.c would free an incomplete transfer when libusb_handle_events_completed exits with an error twice in a row. But we should never free an incomplete transfer, otherwise we may end up referencing free-ed memory later on. This patch simply logs an error and keeps on trying until the transfer completes. Note that if libusb_handle_events_completed keeps throwing an error the entire time, without ever completing the transfer, this patch effectively replaces a potential crash / unspecified behavior, with an endless loop and logging a ton of errors making clear what is going on. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit cb96ec5b4728a2d1cfc9bdf2c32e9e8c98ed074e Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 20 12:41:00 2013 +0200 Revert "Core: Don't wait for completion if cancel_transfer failed" This reverts commit 2f5023c41d3176e56bf0abc521b7c5f8b1ac4664. 2f5023c4 was an attempt to fix: https://github.com/libusbx/libusbx/issues/76 As seen in: http://libusbx.1081486.n5.nabble.com/Libusbx-devel-libusb-interrupt-transfer-does-not-return-in-case-of-error-td626.html [372849.680990] [0000275b] libusbx: error [reap_for_handle] reap failed error -1 errno=14 [372849.681752] [0000275b] libusbx: error [handle_events] backend handle_events failed with error -1 [372850.680466] [0000275b] libusbx: warning [handle_timeout] async cancel failed -5 errno=22 The problem begins with reap_for_handle failing with errno == 14, which is EFAULT. So the real problem is the application passing in an invalid (or too short) buffer, and thus is an application bug. The fix masks this problem, but causes the problem of calling libusb_transfer_free() on a non finished transfer, so it is no good. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Conflicts: AUTHORS libusb/version_nano.h commit 2e5bc1013423812bb9397fce16b7646eb063a148 Author: Ilya Konstantinov <ilya.konstantinov@gmail.com> Date: Thu Jun 20 12:00:46 2013 +0200 Use Android logging when building on Android Closes #101 Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit b0f7e06bac88dc97b2143f46af7ea0f2d32da467 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 20 11:51:38 2013 +0200 Linux: Fix get_kernel_driver_active() when another app has claimed the interface When another app has claimed the interface, IOCTL_USBFS_GETDRIVER will succeed and report a driver of "usbfs" being attached. Since this is not a regular kernel-driver (and detach_kernel_driver does not detach it), get_kernel_driver_active() should return 0 in this case. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 12b18c3b633b0db4dbfeb15a9004dfc64486a5c5 Author: Pete Batard <pete@akeo.ie> Date: Wed Jun 19 22:44:58 2013 +0100 Core: fix another compiler warning in libusb_setlocale() * VS2012 (64 bit) produces the following in strerror.c(156): warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data commit 4935ff097ba93403391340d75f56f52e50112a54 Author: Ludovic Rousseau <ludovic.rousseau@gmail.com> Date: Wed Jun 19 13:21:06 2013 +0200 Core: fix compiler warning in libusb_setlocale() Hello, A small patch for: strerror.c: In function 'libusb_setlocale': strerror.c:148: warning: comparison between signed and unsigned strerror.c:152: warning: comparison between signed and unsigned -- Dr. Ludovic Rousseau From a4144845845cd0a06fb9074ba2d6669ece3a5b1a Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Wed, 19 Jun 2013 13:16:31 +0200 Subject: [PATCH] Core: fix compiler warning in libusb_setlocale() strerror.c: In function 'libusb_setlocale': strerror.c:148: warning: comparison between signed and unsigned strerror.c:152: warning: comparison between signed and unsigned Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 88828bd7c8323cefe307e4e9856daf7e9812d4d5 Author: Luca Longinotti <l@longi.li> Date: Mon Jun 17 09:22:23 2013 +0200 Fix several -Wconversion warnings from GCC inside the static inline functions. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 02281fda6ee5ed7456f381105d159e15dc1b6da6 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Jun 14 11:06:47 2013 +0200 examples: use libusb_set_auto_detach_kernel_driver() What better way to show how useful libusb_set_auto_detach_kernel_driver() is, then to use it in our examples? Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 08befee03cff76f62918a82d92696aa84d01515c Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 13 22:37:29 2013 +0200 linux_usbfs: Work around a driver binding race in reset handling I've been seeing these intermittent failures to reclaim an interface after a device reset. After much debugging and inserting sleeps in strategic places to make the race window larger I've found the following race: 1) A user is running some software using libusbx which will automatically detect, and "bind" to, any newly plugged in USB-devices. For example a virtual machine viewer with automatic USB-redirection 2) The user plugs in a new usb-storage device 3) The usb-storage driver is not yet loaded, udev spawns "modprobe usb-storage", this blocks on disk-io 4) The libusbx app opens the device, claims all interfaces, does a device-reset 5) While the IOCTL_USBFS_RESET is running the modprobe completes 6) The driver registration blocks on an USB lock held by the reset code path 7) When the reset finishes the driver registration completes and the driver binds itself to the device, before IOCTL_USBFS_RESET returns to userspace 8) libusbx tries to re-claim all interfaces it had claimed before the reset 9) libusbx fails as usb-storage is now bound to it This patch works around this issue by simply unbinding the driver for all interfaces which were claimed before the reset. Normally this is a no-op as no driver (other then usbfs) can be bound for claimed interfaces before the reset. This patch also improves the error logging, and makes libusb_device_reset properly return an error when re-claiming fails. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit d4e993192aa81a1867bddf90d53cf750ec21e7b1 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 13 21:49:01 2013 +0200 linux_usbfs: Add support for new disconnect-and-claim ioctl Currently the linux_usbfs detach_kernel_driver_and_claim() helper function makes 3 system calls: 1) IOCTL_USBFS_GETDRIVER, to check the driver is not usbfs 2) IOCTL_USBFS_DISCONNECT 3) IOCTL_USBFS_CLAIMINTF Between each of these calls the state of the interface can change, and things might not work as expected when it does, iow this is inherently racy. To fix this a new IOCTL_USBFS_DISCONNECT_CLAIM ioctl has been added to the kernel a while back, which does all 3 in one. This patch adds support for this ioctl, with a fall back to the old method for kernels lacking this new ioctl. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit fc51f19341af70508b94c06ff763842b396ea72e Author: Hans de Goede <hdegoede@redhat.com> Date: Thu Jun 13 21:21:14 2013 +0200 libusb: Add auto-detach-kernel-driver functionality Add auto-detach-kernel-driver functionality, and a libusb_set_auto_detach_kernel_driver() function. Note that I went with a libusb_set_auto_detach_kernel_driver() function, rather then with a libusb_enable_auto_detach_kernel_driver(), so that apps can also disable it again. This is necessary to handle 2 corner cases: 1) When an app wants to do a libusb_set_configuration after claiming 1 or more interfaces, it needs to first release the interface(s), and in this case libusb_release_interface() should *not* (re-)attach the kernel driver 2) Some usb classes use multiple interfaces for one function, ie usb-audio devices do this. In this case attaching the driver will fail until all interfaces are released, so the app should first release all interfaces, and only then (re-)attach the kernel driver. auto-detach-kernel-driver functionality is still useful for these apps, since doing libusb_detach_kernel_driver() followed by libusb_claim_interface() in 2 separate calls is inherently racy, but they need to be able to disable the auto-detach functionality before releasing interfaces to be able to properly handle the 2 described corner cases. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 6b3931526db981e3a298a226e5d0b4e20c04913d Author: Hans de Goede <hdegoede@redhat.com> Date: Wed Jun 19 10:46:19 2013 +0200 linux_udev: Fix spelling of guarantee in comment Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 672ddae8ca26bb52378c74d1730f533593380727 Author: Chris Dickens <christopher.a.dickens@gmail.com> Date: Fri Jun 14 10:54:29 2013 -0700 POSIX: Set usbi_pipe to non-blocking by oring O_NONBLOCK to fd flags. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit d8c714207df93d2f0d121520c5f2f81efc1f9431 Author: Hans de Goede <hdegoede@redhat.com> Date: Mon Jun 17 08:39:21 2013 +0200 linux_udev: Don't free the udev_monitor while the event thread may still use it Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 1cf2969bc8e696118bb639c787d68fc324690f88 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Jun 14 11:51:38 2013 +0200 linux_udev: Join the hotplug-event-thread when we stop event monitoring To ensure that it is stopped before we continue (and if later libusb gets re-initialized start another thread). Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit f9ef58d8c4fea65152938c2bc7b8bff60d4a14a6 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Jun 14 11:10:35 2013 +0200 libusb_get_bos_descriptor: Don't log an error on devices without a BOS An error of LIBUSB_ERROR_PIPE simply means the device has no BOS, so don't log an error to the console for this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 4d099d08a99aff38c72e393d7eef94b6436d39f8 Author: Chris Dickens <christopher.a.dickens@gmail.com> Date: Thu Jun 13 10:59:11 2013 -0700 hotplug: ensure udev monitor fd is non-blocking Some older versions of udev do not automatically set the udev monitor fd to non-blocking mode. This patch ensures that this is always set. HdG: Get flags then or in O_NONBLOCK and set them, rather then setting flags to only O_NONBLOCK. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 41091f7a6ba7b0243f064b1999f7b4af84f6c3cf Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Jun 14 09:37:05 2013 +0200 linux_udev: Log error code on pthread_create failure Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit cf8a313b2cdb6a25f00730452aab9130cac5c52b Author: Ludovic Rousseau <ludovic.rousseau@gmail.com> Date: Mon Jun 10 15:27:23 2013 +0200 Examples: add a missing \n at end of error messages commit 511ed18228dd097dfe6d5c6fd926eaea24435f64 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri Jun 7 19:07:16 2013 +0100 Core: Add a libusb_strerror() function This patch adds the much requested libusb_strerror() function, taking into account all issues people raised wrt previous attempts. Criteria / Decisions underlying this implementation: - Must support translated messages - Must not use gettext as that does not work well in combination with Windows (when building with Visual C, or for Windows CE) - API compatible with FreeBSD and various patched libusb-s floating around - KISS: - Do not add any (other) library dependencies - Do not try to deal with message encodings (iconv), simply always return UTF-8 making encoding the problem of the application using libusb_strerror. - Defaults to English, so apps which don't want translated messages, don't need to do anything special - Defaults to English (with pure ASCII messages), so apps which don't call libusb_setlocale() don't need to worry about encoding create mode 100644 libusb/strerror.c commit 57576c35268c9b598497f0de891928262e29071e Author: Nathan Hjelm <hjelmn@me.com> Date: Mon May 20 08:20:33 2013 -0600 darwin: return correct error code from libusb_get_config_descriptor when the configuration is not found commit 936796f4a6198c67c33f462b33d9ddb5daacc3b7 Author: Nathan Hjelm <hjelmn@me.com> Date: Thu May 16 22:04:18 2013 -0600 darwin: increment the reference counter to the parent device commit 83331a1182d71d4bcd23304229a8c6ec530f6229 Author: Nathan Hjelm <hjelmn@me.com> Date: Thu May 16 20:48:56 2013 -0600 darwin: avoid enumerating devices more than once This patch attempts to avoid enumerating devices multiple times by keeping a cache of device information (IOUSBDeviceInterface pointers, device descriptors, etc) between calls to libusb_init(). This should avoid two potential problems: 1) Devices that respond slowly to DeviceRequest. These devices can take multiple seconds to respond and they usually respond with a failure (on older versions of OSX at least). By keeping track of these devices the penalty for enumerating them will be paid only once. 2) Repeated enumeration of the same device may cause IOCreatePlugInInterfaceForService() to fail. The root cause of this problem is not well understood but might be a leak in IOUSBFamily. To clean up the cached device information an atexit() function is used. commit c35629939bde68ea7ee520ae8577288a36f0a9b7 Author: Pete Batard <pete@akeo.ie> Date: Wed May 29 12:42:05 2013 +0200 Windows: Fix broken WDK compilation Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit f51b19db343a64b2294fa46fd1b55f8ec6e65751 Author: Peter Stuge <peter@stuge.se> Date: Tue May 8 19:50:17 2012 +0200 examples: Add sam3u_benchmark isochronous example by Harald Welte Copied with the author's permission under LGPL-2.1 from usb-benchmark-project/host/benchmark.c in git://git.gnumonks.org/sam3u-tests.git commit 74959f7ee88f1597286cd435f312a8ff52c56b7e http://git.gnumonks.org/cgi-bin/gitweb.cgi?p=sam3u-tests.git;a=blob;f=usb-benchmark-project/host/benchmark.c;h=74959f7ee88f1597286cd435f312a8ff52c56b7e An Atmel SAM3U test firmware is also available in the above repository. Conflicts: .gitignore Signed-off-by: Hans de Goede <hdegoede@redhat.com> create mode 100644 examples/sam3u_benchmark.c commit d7b796f1fe3d0aeee3ab2fc717eac38fec8d5caa Author: Hans de Goede <hdegoede@redhat.com> Date: Mon May 27 16:31:48 2013 +0200 Add BOS descriptor support Based on earlier work done on this by Maya Erez <merez@codeaurora.org>, Nathan Hjelm <hjelmn@me.com> and Pete Batard <pete@akeo.ie>. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit ef698c633d2ecb597be58deccfa2795cc6c88e25 Author: Hans de Goede <hdegoede@redhat.com> Date: Mon May 27 11:12:28 2013 +0200 Add superspeed endpoint companion descriptor support Based on earlier work done on this by Maya Erez <merez@codeaurora.org>, Nathan Hjelm <hjelmn@me.com> and Pete Batard <pete@akeo.ie>. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit cedc7f6e289c427c84a9175045b06614be56ec5a Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 24 16:15:51 2013 +0200 hotplug: Add a hotplug_poll backend function Apps which were written before hotplug support, may listen for hotplug events on their own and call libusb_get_device_list on device addition. In this case libusb_get_device_list will likely return a list without the new device in there, as the hotplug event thread will still be busy enumerating the device, which may take a while, or may not even have seen the event yet. To avoid this add a new hotplug_poll backend function and make libusb_get_device_list call a this before copying ctx->usb_devs to the user. In this function the backend should ensure any pending hotplug events are fully processed before returning. This patch implements hotplug_poll for linux, it should probably be also implemented for darwin. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 7ced70e14968bd6869a561d2cf8e7ac5a1df8938 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 24 14:40:27 2013 +0200 linux: rework hotplug lock handling I could not find if libudev is completely threadsafe anywhere, so rework the lock handling to serialize all libudev accesses. This is a preparation patch for adding hotplug_poll support, see the next patch in this series. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit d250964e64c97d92460c96fff613b39f55d1378b Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 24 15:52:45 2013 +0200 linux: Add a linux_netlink_read_message helper function Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit d9f30bc50a7451ce38e75e6ec02a67f86b889df5 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 24 14:03:54 2013 +0200 descriptor.c: AlternateSettings are related by InterfaceNumber A block of AlternateSettings for a certain InterfaceNumber does not necessarily start with AlternateSetting 0, so check Interface Descriptors belong to each other by using InterfaceNumber, as specified in the spec. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 462c88702ebc8004f4f6d1e595bf1fc0f5567c45 Author: Toby Gray <toby.gray@realvnc.com> Date: Fri May 24 10:42:56 2013 +0200 WinCE: Add hotplug.c to projects Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 50d9312621e7fe8ef111fb5074b9929e56df86b6 Author: Toby Gray <toby.gray@realvnc.com> Date: Fri May 24 10:38:48 2013 +0200 Windows: Add new symbol for libusb_get_port_numbers to def file Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 3abc6f3ba50bd6fd82b839f698ca2c7fa34ea066 Author: Toby Gray <toby.gray@realvnc.com> Date: Fri May 24 10:36:20 2013 +0200 Hotplug: Make use of HAVE_SYS_TYPES_H define Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 51655d74909fca03209cb5de5b90fb8d4e7dc465 Author: Toby Gray <toby.gray@realvnc.com> Date: Fri May 24 10:35:24 2013 +0200 POSIX: Move setting of pipes to non-blocking into usbi_pipe Signed-off-by: Hans de Goede <hdegoede@redhat.com> create mode 100644 libusb/os/poll_posix.c commit 4527d16c5c22a0d04f65dfadbb20b8a5d762f5fe Author: Simon Haggett <simon.haggett@realvnc.com> Date: Mon May 20 12:40:43 2013 +0100 wince_get_active_config_descriptor() sets host_endian incorrectly wince_get_active_config_descriptor() retrieves configuration descriptors as raw bytes, in bus-endian order. Therefore, host_endian should be set to 0 (as in wince_get_config_descriptor()). Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit cf641bab1e699d12bb44a35949b8dd12970f6b5e Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 24 10:24:57 2013 +0200 all: ensure host_endian is always initialized The get_device_descriptor backend call done from descriptor.c was passing in an uninitialized host_endian value. Likewise for the windows backend, host_endian was not being set from get_[active_]config_descriptor. Since the 2 problem cases are for different backend calls, we were never using an uninitialized host_endian, still lets set it everywhere for safety, Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 6b41074352bec3e8fe132fc74768da8e930a2ab5 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 23 19:51:07 2013 +0200 all: Allow backend to provide a better get_config_descriptor_by_value Our core get_config_descriptor_by_value is not exactly pretty nor efficient, allow the backends to provide something better. Note that the callback signature differs from get_config_descriptor in that backend owned memory gets returned. This saves a needless malloc + memcpy + free. If this turns out to be a problem for some backends we can always change things to work like get_config_descriptor. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit da5b335e0c01650818d8e85973728e288c1f409d Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 23 19:24:48 2013 +0200 descriptor.c: Add a raw_desc_to_config helper function Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit b42954bd5d3c629fa0e2dea740dc5718b04d5082 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 23 17:20:47 2013 +0200 descriptor.c: Consequently check bDescriptorType and bLength everywhere Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 25b314279a6774198cf6de4170c76f458ebc89a2 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 23 15:20:12 2013 +0200 descriptor.c: Read a full config-desc-header on first config-desc read For some reason the first get config call to determine the total-length was only reading 8 of the 9 bytes of a full config-desc-header, which is weird. The Linux kernel reads the full 9 on the first call, so lets do that in libusb too. Note that for backends which cache the config this does not matter. Also check that we've actually gotten back a full header, before parsing it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit bbe25fac47c2dfd2d50a2c3a1b0ed96473d8dc1c Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 23 14:40:05 2013 +0200 all: Make usbi_os_backend.get_[active_]config_descriptor return len Since commit 5e479f1821d3294fb1cc70c5867c69eca2551de7: "Core: Avoid short read failures on broken descriptors" usbi_os_backend.get_[active_]config_descriptor no longer return on error (under Linux) when returning less bytes then requested. But libusb_get_[active_]config_descriptor still not only requests wTotalLength bytes, but also blindly assumes that on success it has gotten wTotalLength bytes. This patch fixes this, it changes all usbi_os_backend.get_*config_descriptor implementations to return the actual length on success and uses this value as the descriptor size in parse_configuration(). Note that the linux and wince backends were already returning the actual length and thus are not touched. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit af06916bed2c7eb3b1a1a144348ebc7478097604 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 23 13:25:08 2013 +0200 linux: Properly deal with invalid config.wTotalLength in sysfs In usbfs wTotalLength can be trusted, in the sense that the kernel simple has holes in the descriptors file when a device returns a smaller config descriptor then advertised. In sysfs this is not the case, sysfs descriptors only contain descriptors actually returned by the device, with no holes. The kernel does validate the bLength field of all the descriptors and removes any invalid ones. So with sysfs we cannot rely on wTotalLength, since we can trust bLength, this patch searches forward for a descriptor with type of LIBUSB_DT_CONFIG to find the next config on sysfs. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit b241dd329cdad2779158e417e086b6a9bb9d6a2d Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 20:45:26 2013 +0200 linux: get_configuration don't return LIBUSB_ERROR_NOT_SUPPORTED with usbfs We have an implementation of get_configuration with usbfs, so lets use it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 200931805bc352219a9f991c46dcb2d6f204c426 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 20:38:51 2013 +0200 linux: Use cached config descriptors Use cached config descriptors instead of doing tons file io, because: - Less fileio is more - Less code is more, diffstat for this patch: 1 file changed, 128 insertions(+), 307 deletions(-) Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 4a34eda8bfe56ea6637a8d549bf4458f93059003 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 15:57:29 2013 +0200 linux: init: Only stop the event monitor if we also started it Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 0d33bb0b31914aeb377ce33d4b9514a009d3cdf8 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 15:48:22 2013 +0200 linux: Switch to kernel version check to determine if sysfs can relate devs We rely on the kernel version for determining capabilities, except for sysfs_can_relate_devices. This changes sysfs_can_relate_devices over to a kernel version check to. This makes things more consistent, removes a whole bunch of code, and since it stops us from needlessly banging sysfs, it reduces the avarage run time for the stress test on my system from 21.8 to 16.7 seconds. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 8f9f21190250306b55423133ee5b38ffc477674e Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 15:25:06 2013 +0200 linux: Switch to kernel version check to determine if sysfs has descriptors With the refactoring of the Linux descriptors handling, we only want to use sysfs descriptors if they have the complete config descriptors (versus just the active config descriptor), which is the case since Linux 2.6.26. This means that we will fallback to using the usbfs descriptors for the device descriptor on Linux 2.6.23 - 2.6.25, which only have the active config descriptor. This will cause a tiny performance penalty, but only on these 3 kernel versions (which are not used in any still supported Linux distros), and then only on library init since we now cache everything. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 24b63efe460b56559437c44a21f9d4b034e8dca8 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 14:52:37 2013 +0200 linux: Clear descriptor buffer before read when using usbfs In usbfs the config descriptors are config.wTotalLength bytes apart, but the device may actually return a shorter descriptor then advertised, in this case the kernel will simply skip over any bytes read which the device did not actually return. Note the kernel will *not* return 0 data, it will simply leave the memory passed in to the read call as is. Therefor this patch clears the buffer before calling read, to ensure that the non existing parts of the descriptors are always properly zero-ed. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit af9997c4085ed0c26b022070ce9f5e19cd8cfec4 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 12:57:32 2013 +0200 linux: Cache the entire descriptors at device-init Now that the core caches device-descriptors, we end up opening each usbfs-node or sysfs-descriptors file once on libusb_init anyways. So we might as well do this on device-init, rather then waiting for the core to call op_get_device_descriptor. This allows us to simplify the code in various places. While we've it open, read the entire file rather then only reading the device-descriptor. This is practically free, since most of the cost is in the opening of the file, not in reading it. Running the stress test, which does 10000 libusb_init calls, takes 21.8 seconds on avarage on my idle system with 17 usb devices both before and after this patch, showing that the cost of also reading the config descriptors while we've the file open is truely neglible. Note that this patch does not yet use the cached config descriptors, this is done by a later patch in this series. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 7201f72f2b21ce90436cae6cf021dc65123a1de6 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 12:40:51 2013 +0200 linux: Add a _get_usbfs_fd helper function Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 1049db5db5592a632a39b899d211dcec9b7de43e Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 22 12:12:28 2013 +0200 usbi_alloc_device: Drop unnecessary memset 0 The memory gets calloc-ed, so there no need to clear it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 9f59875fbce9dc6bdb163e8558761a06400a9f18 Author: Hans de Goede <hdegoede@redhat.com> Date: Sat May 18 14:07:49 2013 +0200 linux: Fix host_endian handling -in 2 cases the passed in host_endian was not being set -get_config_descriptor was wrongly calling seek_to_next_config with host_endian set to 1, but the only case where host_endian is 1 is when reading the device-desc from usbfs, even in usbfs the config descriptors are in raw format Note that the 2nd change partly reverts commit 7f2e9f0776386997d2b4c4c47598ab88e3caeb7a "Linux: Fix usbfs/sysfs config descriptor handling on big-endian" Which commit msg says: "checked against Documentation/usb/proc_usb_info.txt" Well guess what, I checked the actual drivers/usb/core/devio.c code and Documentation/usb/proc_usb_info.txt is *wrong*. I'll send a patch to update it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit f3fcf8402609d946d16eb2d9686bf76d7b0b8ae0 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 17 10:42:47 2013 +0200 Examples: Fix use of deprecated libusb_get_port_path While at it also simplify the path printing in listdevs Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 4d7789be7e317fb2e89557f959c1a1a69cc01b26 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 17 10:36:32 2013 +0200 core: Add a new public libusb_get_port_numbers function This new function replaces the now deprecated libusb_get_port_path function, as that is the only function operating on a libusb_device which also takes a libusb_context, which is rather inconsistent. Note we will keep libusb_get_port_path around in the 1.0.x for the forseeable future for ABI compatibility reasons, but it should not be used in any new code. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit fa27f99772e9200d97518fe2aa7332e892949132 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 17 10:07:25 2013 +0200 core: Fix handle_events return code on hotplug pipe read error Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 858b794cf10ff1ac76a4f453bed7645aa9709c44 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 3 21:19:28 2013 +0200 usbi_handle_disconnect: Fix race condition leading to double completion It took me quite a while to debug this, here is a step by step for the race which I believe is happening in some cases: 1) app calls libusb_submit_transfer 2) libusb_submit_transfer locks itransfer->lock 3) libusb_submit_transfer adds the transfer to the flying list 4) *thread switch* 5) other thread notices POLL_ERR on device fd, calls usbi_handle_disconnect 6) usbi_handle_disconnect find the transfer which is in progress of being submitted in the flying list 7) usbi_handle_disconnect calls usbi_backend->clear_transfer_priv on the transfer, this blocks waiting on itransfer->lock 8) *thread switch* 9) libusb_submit_transfer actually tries to submit the transfer now, calls usbi_backend->submit_transfer, which fails with -ENODEV 10) libusb_submit_transfer *removes* the transfer from the flying list, unlocks itransfer->lock and returns an error to its caller 11) the caller frees the transfer, meaning the to_cancel pointer in usbi_handle_disconnect now points to free-ed memory, for extra mayhem 12) *thread switch* 13) usbi_handle_disconnect calls usbi_handle_transfer_completion 14) usbi_handle_transfer_completion tries to remove the transfer from the flying list *for the 2nd time* But the first call done from libusb_submit_transfer has already done this. libusb's list_del looks like this: static inline void list_del(struct list_head *entry) { entry->next->prev = entry->prev; entry->prev->next = entry->next; entry->next = entry->prev = NULL; } So the first call sets it next and prev to NULL, and then the 2nd call tries to deref next -> BOOM For an example backtrace caused by this, see: https://bugs.freedesktop.org/show_bug.cgi?id=55619#c7 This patch fixes this by letting libusb_submit keep the flying transfers list locked during submission, so the submission flow changes from: 1) lock flying transfers add to flying transfers unlock 2) submit 3) on submission error: lock flying transfers remove from flying transfers unlock to: 1) lock flying transfers 2) add to flying transfers 3) submit 4) on submission error: remove from flying transfers 5) unlock This means that the os backends submit handler now gets called with the flying transfers lock held! I've looked at all the backends and this should not be a problem. Only the windows and win-ce backends care about the flying transfers list at all, and then only in their handle_events handler. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 84d53288970f0d72d43629a8125b332bcebdc8b0 Author: Hans de Goede <hdegoede@redhat.com> Date: Fri May 3 20:19:06 2013 +0200 usbi_handle_disconnect: Add some debugging wrt cancelled transfers Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit a56fbe7977f0c4780f78f8ed07e2e410abe61139 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 22:40:13 2013 +0200 linux: linux_get_parent_info: properly propagate malloc errors Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit ebac6ac1b30aea6e9190cce336eb75dc0f1c5ce7 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 22:36:26 2013 +0200 listdevs: Also print portpath for non root hubs Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 6391d86e818bf4ed63842cad278c2fb2572dc5d8 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 22:09:58 2013 +0200 All: ref dev->parent_dev An app can hold a reference to just a leave device, if then an entire hub goes away, all removed devices will get there final unref, except for the one ref-ed by the app. If the app then tries to use parent_dev in anyway after this, we've a use-after-free bug. This fixes this. Also remove the lets re-enumerate fix for this from libusb_get_port_path, I'm not sure what the exact idea behind this fix was, but after this patch it is no longer needed, and this patch also fixes usage of for example libusb_get_parent(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit c235fa2f9d90b6f65f75c545e90596545879ca4f Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 21:50:50 2013 +0200 core: Improve error / debug messages for hotplug pipe handling Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 631d1ae168e66d802f3a635a60ee0a6724a6d7c7 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 21:31:31 2013 +0200 linux: Fixup init_count tracking on hotplug init error Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 34e5d1888f6b7a110b6e4854825a61bef9ac3e6b Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 21:30:42 2013 +0200 linux_udev: linux_start_event_monitor: Properly cleanup on error Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 972e9cde6e93796731871fa758b26c11a6621195 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 21:18:11 2013 +0200 linux: Replace should-not-happen checks with asserts These all really should never happen, so rather then to do error handling when they do, simple assert them. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 36463b0bf0576ab2c00aa1dd853294feef4a3652 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 20:49:01 2013 +0200 linux: Not finding a device on hotplug_disconnect is not an error This can happen if the device gets removed between registering the hot-plug event handler and initial device enumeration running. So lets turn this into a debug message to avoid spurious bug-reports. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 2e53d2662f2b78e73132cd381f36390558cf088f Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 20:46:07 2013 +0200 linux: Improve topology related debug messages And use usbi_dbg, rather then fprintf(stderr, ... Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 3a1bdebf116775294b845385371339b5254a6b7d Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 20:37:51 2013 +0200 linux: Set device->port_number Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit cf46b17f8287c1a6650687ad4f84bb05fbbe213e Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 17:13:11 2013 +0200 linux: Deal with devices being enumerated before their parents are The linux netlink enumeration code processes devices in readdir order, which means devices may get enumerated before their parent is, IE on my system readdir order is (ls -U) 1-1 usb4 2-1.8 6-0:1.0 1-1.4.3 1-1.4.4.1:1.0 2-1 usb5 6-1.4 6-1:1.0 1-1.4.4 1-1.4.4.1:1.1 6-1 usb6 3-0:1.0 2-1.8:1.0 1-0:1.0 1-1.4.4.1:1.2 7-1 usb7 1-1.4.3:1.0 2-1.8:1.1 1-1:1.0 usb1 1-1.4.4.1 1-1.4.4:1.0 2-1.8:1.2 6-1.4:1.0 usb2 1-1.4:1.0 4-0:1.0 7-0:1.0 2-0:1.0 usb3 1-1.4 5-0:1.0 7-1:1.0 2-1:1.0 So 1.4.4.1 will get added (way) before 1.4.4 and indeed: [ 0.002243] [00004055] libusbx: debug [linux_get_device_address] scan 1-1.4.4.1 Dev 0x1973bc0 (1-1.4.4.1) has parent (nil) This patch fixes this by forcing enumeration of the parent from linux_parent_dev. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit f168b3d23f8cff5d5986ddbd7c0dffcd5cb91347 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 17:02:08 2013 +0200 linux: Move check for a device being added twice to linux_enumerate_device It is possible for a device to show up between the hotplug code starting to listen for new devices, and the enumeration of existing devices. This will cause a device to get enumerated twice. The next patch in this series adds a different code path which can cause a device to be enumerated twice, this patch therefor moves the check for this to linux_enumerate_device, so that this will get caught in all cases. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 9f679a9c9abc430614f9d6654c40bee9c64c84be Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 16:56:40 2013 +0200 linux: hotplug_enumerate and _disconnect take active_contexts_lock Take the active_contexts_lock when enumerating over active_contexts. Note that the active_contexts_lock is taken *before* the hotplug lock, as they are taken in the same order in the libusb_init path. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 2d08a3e6da873cab069780f7e6c478299afe759a Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 16:54:02 2013 +0200 linux: Replace pthread_mutex with usbi_mutex_static Boils down to the same thing, but mixing and matching lock types in one file looks ugly. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 4ea8e4a1b99e6ff5578dd2c7e0d2f7bbfd1631b3 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 16:43:24 2013 +0200 core: Fixup default_context handling Now that we set the default context earlier in libusb_init: -There is no need to do it a second time at the end of libusb_init -We need to set it to NULL if libusb_init fails later on -Since it now can be set then reset by libusb_init, libusb_exit needs to take the lock while testing if the passed in ctx == default_context Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit fc8be23868ef1161278e978568ff630f27132cb3 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 16:38:41 2013 +0200 core: Fixup cleanup on init error -mutexes were not being destroyed on backend init failure -hotplug_cbs_lock mutex was never being destroyed Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 851b2570532174779670587b58240f5d91ddec36 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 16:32:33 2013 +0200 core: Add ctx to the active context list before backend->init As soon as backend->init has completed hotplug events may fire, and they will not get processed on the created context until it has been added to the active_context list. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 6270638991a56489128955699e37d5ca33f30f83 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 16:21:23 2013 +0200 linux: Take hotplug_lock for scan_devices, hotplug_enumerate and _disconnect As soon as we've started listening for hp events, hotplug_enumerate and _disconnect can run, they do test then add / remove operations on the device list. This can race with scan_devices adding devices, so take the lock around all 3 to avoid the race. Also fix the lock not being released in case of linux_start_event_monitor failure. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 50f79a1ada1df394dfeac4975e37b087a124e321 Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 15:02:12 2013 +0200 linux: linux_parent_dev search for . from the right If hubs are chained to other hubs there will be multiple '.' characters, and want the last one. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 8ad7e5ad5124b77707b3dcb844f469592c2ec43b Author: Hans de Goede <hdegoede@redhat.com> Date: Thu May 16 13:08:58 2013 +0200 configure: Fix --enable-udev help text We use AC_ARG_ENABLE so the help string should be --enable-udev, so that the user knows to pass --disable-udev to disable udev Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 99660ec22eeef66591e850b6e94dd6b6bbe514b9 Author: Nathan Hjelm <hjelmn@me.com> Date: Wed May 15 07:54:53 2013 -0600 linux: fix topology Find the parent dev by removing the last number after the . or - (and prepending with usb if only one number is left) and comparing it against the sysfs_dir or previously scanned devices. HdG: Drop hardcoded special casing of root-hubs, this is fixed in a better way in a later commit. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 8a76406d91d66eb63898ad6b94a0c0c8d27fb3e0 Author: Nathan Hjelm <hjelmn@me.com> Date: Tue May 14 19:25:55 2013 -0600 darwin: fix topology The parent device should always already be in the context when a device is processed. Use the parent device's location to find the parent dev. Note: we might want to replicate the notion of a locationID in the core. If done right the parent dev could be determined in the core. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 4b23b75cc464d463f21978ebab00b9cf392254fd Author: Nathan Hjelm <hjelmn@cs.unm.edu> Date: Fri Dec 7 19:55:21 2012 -0700 darwin: clean up extraneous includes Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 7e858a3408e71a7aa24327e80e495b57f0b8b999 Author: Pete Batard <pete@akeo.ie> Date: Wed May 15 17:39:47 2013 +0200 Add hotplugtest to msvc project files create mode 100644 msvc/hotplugtest_2010.vcxproj create mode 100644 msvc/hotplugtest_2010.vcxproj.filters create mode 100644 msvc/hotplugtest_2012.vcxproj create mode 100644 msvc/hotplugtest_2012.vcxproj.filters create mode 100644 msvc/hotplugtest_sources commit 4198182d19307040931f44d8d4ce97f254f4e434 Author: Pete Batard <pete@akeo.ie> Date: Wed May 15 17:34:01 2013 +0200 Misc fixes Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit a1b0ae5e594812f69b0114292a1d5eec9e891207 Author: Peter Stuge <peter@stuge.se> Date: Tue May 8 19:22:31 2012 +0200 examples: Only check for HAVE_SIGACTION once in Makefile.am Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit cedfca68a8ca74054182cb44e7fef3b0638d0033 Author: Hans de Goede <hdegoede@redhat.com> Date: Wed May 15 16:19:02 2013 +0200 Add INSTALL_WIN.txt eol=crlf to .gitattributes Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 57256dd1597c9b8641bef1596edbeddc4348dd86 Author: Nathan Hjelm <hjelmn@me.com> Date: Wed May 15 16:11:22 2013 +0200 Add some editor meta-comments for proper tab usage Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 6e501b377dd0bccaefce5604616614deb2abb3fc Author: Sean McBride <sean@rogue-research.com> Date: Fri Oct 12 17:34:25 2012 -0400 Core: use C99 flexible array member when possible Fix clang warning by using C99 flexible array member instead of zero length array gcc extension Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit b247ea165cf5662fa76876662dbc5ea77a020b07 Author: Nathan Hjelm <hjelmn@me.com> Date: Fri May 3 08:03:37 2013 -0600 darwin: return LIBUSB_ERROR_NOT_FOUND when reading the active config descriptor when the device is not configured. fixes #172 Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 2bb148be9754625d86e1ea1bbc8a6542c9f9ad61 Author: hjelmn@cs.unm.edu <hjelmn@cs.unm.edu> Date: Tue Apr 23 16:35:33 2013 -0600 darwin: clean up old code For some time only one type of completion message has been in use in the darwin backend. The commit cleans up this code. This commit also removes some code that has never done anything useful. If a pipe has an error it probably means the device was closed so there is nothing to do. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 91deff8f6bf3041855f014533dfaa81b75e0b5f9 Author: Nathan Hjelm <hjelmn@me.com> Date: Thu Apr 25 21:12:45 2013 -0600 darwin: fix memory leaks in the darwin backend. There were two memory leaks in the darwin backend: - A CFString allocated by IORegistryEntryCreateCFProperty in darwin_get_interface() was not released. - The runloop is retained by darwin_open() but was not release by darwin_close(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 8dfb979df12cdf95d4156156cee02bc2f64adb16 Author: Nathan Hjelm <hjelmn@me.com> Date: Thu Apr 25 21:09:19 2013 -0600 core: release the context device list when the context is deleted. This commit fixes a memory leak in the context list patch. Devices need to be unref'd when the context is deleted. This can happen if either 1) the backend init fails, or 2) the context is destroyed by libusb_exit(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit bae927f89624a1ccdaea9581e5e6d57c7675e72c Author: Nathan Hjelm <hjelmn@cs.unm.edu> Date: Tue Apr 2 22:12:47 2013 -0600 darwin: don't assume an interval of 1 or high/super speed This patch updates submit_iso_transfer to use the bInterval value of the endpoint and the speed of the device to determine the last frame of the transaction. Fixes: #165 Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit ae712a7be927d3ee4ed81ceae06a839f872fe8ff Author: Nathan Hjelm <hjelmn@cs.unm.edu> Date: Fri Feb 8 00:12:13 2013 -0700 darwin: add support for the LIBUSB_TRANSFER_ADD_ZERO_PACKET transfer flag. The zero-length packet is sent by the async event thread if all the following conditions are met: 1) The packet size is not a multiple of maxPacketSize, and 2) the transfer completed successfully. References #6. Signed-off-by: Hans de Goede <hdegoede@redhat.com> commit 7598cc176c844d50dac6287b919fafca02cf5d08 Author: Nathan Hjelm <hjelmn@cs.unm.edu> Date: Thu Feb 7 21:56:30 2013 -0700 darwin/libusb_reset: reenumerate device if the device descriptor or any configuration descriptor has ... |