summaryrefslogtreecommitdiff
path: root/libusb
AgeCommit message (Collapse)AuthorFilesLines
2013-09-28linux: take newline into account for sysfs_get_active_configKarsten Koenig2-2/+2
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
2013-09-20examples: Fix a memory leakLudovic Rousseau1-1/+1
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.
2013-09-20examples: Fix a memory leakLudovic Rousseau1-1/+1
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.
2013-09-15Fix darwin compilation broken by the usbi_get_device_by_session_id changesHans de Goede2-2/+2
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-09-06Make usbi_get_device_by_session_id return a ref to the found deviceHans de Goede9-28/+26
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-09-06openbsd: Fix a memleakHans de Goede2-2/+5
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>
2013-09-06openbsd: Fix usbi_sanitize_device error handlingHans de Goede2-2/+4
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>
2013-09-06Release 1.0.17Hans de Goede2-2/+2
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-09-02Windows: Address an VS2012/x64 warning in hotplug.cXiaofan Chen2-2/+2
..\libusb\hotplug.c(255): warning C4244: '=' : conversion from 'ssize_t' to 'int', possible loss of data
2013-08-30Nathan is a maintainer now, so add him to the READMEHans de Goede1-1/+1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-30Remove unused THANKS fileHans de Goede1-1/+1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-30Makefile.am: Add Xcode dir to EXTRA_DISTHans de Goede1-1/+1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-30Android: Add android build files to source tarballToby Gray1-1/+1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-28Release 1.0.17-rc1Hans de Goede2-3/+3
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-26darwin: return libusb error codes instead of kernel error codes and fixNathan Hjelm2-4/+6
a bug introduced in the last commit.
2013-08-26darwin: clean up some code. remove a clang warningNathan Hjelm2-12/+8
The check for NULL != cached_device was unnecessary and caused clang's static analysis to print out a warning.
2013-08-21Android: Add further documentation to Android README fileToby Gray1-1/+1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-21OpenBSD: Add basic support for non ugen(4) devices using usb(4)Martin Pieuchot2-123/+212
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>
2013-08-21openbsd: Split openbsd backend into separate openbsd and netbsd backendsHans de Goede5-3/+745
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>
2013-08-21Clarify alignment requirements for the control transfer bufferPaul Fertser3-5/+7
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>
2013-08-21linux: Handle device disconnection early when possibleChris Dickens5-6/+25
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>
2013-08-21hotplug: Document LIBUSB_HOTPLUG_ENUMERATE gotchasHans de Goede2-1/+13
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>
2013-08-21hotplug: Document that callbacks cannot unregister themselves when called ↵Hans de Goede2-2/+6
from hotplug_register_callback Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-21hotplug: Don't call the user callback while holding various locksHans de Goede2-8/+18
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>
2013-08-20hotplug: Remove device from usb_devs before signalling its removalHans de Goede2-5/+5
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>
2013-08-20libusb: Fix usb_devs_lock mutex use after free in libusb_init error pathHans de Goede2-5/+5
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-14linux/netlink: correct usage of fcntlNathan Hjelm1-2/+9
Closes #130
2013-08-13Windows: Fix a cast warning when compiling for x64 in VSPete Batard2-2/+2
* Also fixes and closes #129 again
2013-08-12Windows: Fix VS2010 project filesPete Batard1-1/+1
* Closes #129
2013-08-11Android: Add examples and stress testsToby Gray1-1/+1
2013-08-11Android: Add formal Android supportToby Gray3-27/+14
* Also fix an issue with LIBUSB_LOG_LEVEL_NONE
2013-08-09Core: Add compile time option to use native OS logging facilityToby Gray2-6/+33
* 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.
2013-08-07linux: ensure the netlink socket is correctly opened with older Linux kernelsNathan Hjelm2-7/+31
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.
2013-08-07Core: Fix potential segfault caused by using freed memoryChris Dickens1-1/+2
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.
2013-08-08Windows: Fix race between windows_clock_gettime_threaded() and ↵Simon Haggett2-2/+13
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
2013-08-08WinCE: Fix race between wince_clock_gettime_threaded() and wince_clock_gettime()Simon Haggett2-2/+13
* 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
2013-08-08Windows: fd_to_winfd() shouldn't treat fd 0 as invalidSimon Haggett1-1/+1
* 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
2013-08-02README: Add OS X specific notesSean McBride1-1/+1
Xcode 4.3 do not provide autotools anymore. libusbx now provides a Xcode project to ease build Mac OS X.
2013-08-02Core: correctly check usbi_read() returned valueChris Dickens2-3/+3
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.
2013-08-02Core: defensive programmingSean McBride2-3/+5
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.
2013-07-30darwin: fix clang warnings about explicit conversionhjelmn2-4/+4
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.
2013-07-30fixed link errors by adding missing files to Xcode projectSean McBride1-1/+1
2013-07-30made some globals static to fix warningsSean McBride2-2/+2
2013-07-30fixed some clang -Wdocumentation warnings from bad doxygen markupSean McBride3-4/+4
2013-07-30fixed compiler warning about possible uninitialized use by zero initializingSean McBride2-2/+3
2013-07-30make targets for examples depend on library target. Generate library named ↵Sean McBride1-1/+1
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
2013-07-30Xcode: build for 32 and 64 bitsLudovic Rousseau1-1/+1
2013-07-30Xcode: remove implicit/default configurationLudovic Rousseau1-1/+1
2013-07-30Add minimal config.h for XcodeLudovic Rousseau1-1/+1
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.
2013-07-30Adapt Xcode project to the new pathsLudovic Rousseau1-1/+1