Permalink
Branch: master
Commits on Feb 8, 2019
  1. Fixed -Wformat warnings by casting intptr_t to void*

    seanm authored and LudovicRousseau committed Jan 17, 2019
    %p is for pointers, not integers; therefore added a cast.
    
    Fixes the following warnings:
    libusb/core.c:1252:33: Format specifies type 'void *' but the argument has type 'intptr_t' (aka 'long')
    libusb/core.c:1276:45: Format specifies type 'void *' but the argument has type 'intptr_t' (aka 'long')
    
    Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
Commits on Jan 31, 2019
  1. haiku_usb_raw: Add missing wrap_sys_device field to usbi_os_backend

    i80and authored and hjelmn committed Jan 25, 2019
    Closes #527
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  2. haiku_usb_raw: return written length instead of LIBUSB_SUCCESS

    i80and authored and hjelmn committed Jan 24, 2019
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  3. Fixed many compiler warnings about sign and size mismatch

    seanm authored and hjelmn committed Dec 15, 2018
    - added various casts
    - added some asserts where the casts made assumptions
    - enabled additional warnings in Xcode project (especially -Wshorten-64-to-32)
    
    Closes #509
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  4. fix race condition at event_handles

    nxpfrankli authored and hjelmn committed Jan 11, 2019
    event_handles supposed just run at a thread.
    
    There are re-entry check at begin.
    
    1: if (usbi_handling_events(ctx))
    2:	return LIBUSB_ERROR_BUSY;
    
    3: usbi_stat_event_handle(ctx);
    
    this code is hold any lock
    
    it is possible two thread check 1 at the same time, then
    go through to 3. So two threads will run event_handles.
    
    above 3 line code should hold event_data_lock to avoid above
    race condition.
    
    1: usbi_mutex_lock($ctx->event_data_lock);
    2: r = 0;
    3: if (usbi_handling_events(ctx))
    4: 	r = LIBUSB_ERROR_BUSY;
    5: else
    6: 	usbi_start_event_handling(ctx);
    7: usbi_mutex_unlock($ctx->event_data_lock);
    
    8: if(r)
    9:	return r;
    
    check and set in an atomic operations.
    
    Closes #520
    
    Signed-off-by: Frank Li <Frank.Li@nxp.com>
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  5. Add missing structure entry to avoid erroneous shift of following items

    winterrace authored and hjelmn committed Jan 26, 2019
    Closes #526
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Commits on Jan 17, 2019
  1. darwin: use internal define when querying plugin interface

    hjelmn committed Jan 17, 2019
    Apple changed the definition of kIOUSBInterfaceInterfaceID in the SDK
    for macOS 10.14. This looks like it breaks support for building for
    older macOS versions when running 10.14. I don't know if the change
    was intentional or a mistake but in order to guarantee libusb
    builds as it has in the past we can no longer rely on
    kIOUSBInterfaceInterfaceID.
    
    Closes #519
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Commits on Jan 9, 2019
  1. darwin: shorten hotplug poll timeout

    hjelmn committed Jan 9, 2019
    Looks like 5 seconds was indeed too long. Shortened the timeout to
    1ms instead.
    
    Closes #516
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  2. linux_usbfs: Disable hotplug events and scanning on Android

    vianney authored and hjelmn committed Dec 13, 2016
    On Android, the platform API should be used to scan for and open devices
    and pass file descriptors to libusb.  Newer devices (Android 5+) even
    prohibit listening for hotplug events, resulting in libusb failing to
    initialize without this patch.
    
    Note that this patch effectively renders libusb useless on older devices
    that do not have USB support in the platform API (anything before
    Android 5).
    
    Closes #242
    
    Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  3. linux_usbfs: Use fallback usbfs path on Android

    vianney authored and hjelmn committed Mar 15, 2016
    On newer Android devices (5+), SELinux policies block normal processes
    from reading /dev.  The consequence is that the usbfs path cannot be
    found.  Rather than failing to initialize libusb in such case, fall back
    to /dev/bus/usb.  This path will actually not be used, as USB devices
    should be opened through the Android API, passing the file descriptor to
    libusb_wrap_sys_device.
    
    Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  4. linux_usbfs: Implement libusb_wrap_sys_device()

    vianney authored and hjelmn committed Dec 13, 2016
    Add support for the libusb_wrap_sys_device() API on Linux.  Because
    sysfs_dir is set to NULL, only the provided file descriptor will be
    used.  This is needed on some platforms (e.g., Android) where sysfs
    might not be available.
    
    Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  5. core: Add libusb_wrap_sys_device() API

    vianney authored and hjelmn committed Dec 13, 2016
    Introduce a new API function for wrapping an existing platform-specific
    device handle as a libusb_device_handle.
    
    Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  6. linux_usbfs: Get device address from file descriptor

    vianney authored and hjelmn committed Dec 13, 2016
    Extend linux_get_device_address() to try to read the device address from
    a file descriptor as a last resort, if provided.
    
    Additionally, linux_get_device_address() will now return an error if the
    path could not be parsed.
    
    Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  7. linux_usbfs: Extract device handle initialization from op_open()

    vianney authored and hjelmn committed Dec 13, 2016
    Slightly refactor op_open() to extract the device handle initialization
    code into a new initialize_handle() function, similar to the
    initialize_device() function.
    
    Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  8. linux_usbfs: Fallback to usbfs if device has no sysfs_dir

    vianney authored and hjelmn committed Dec 13, 2016
    Handle devices that are initialized with NULL as sysfs_dir.  For such
    devices, the usbfs functions should be used instead of their sysfs
    counterparts.
    
    Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  9. Tried to untangle mixing of int, enum libusb_error, kern_return_t, an…

    seanm authored and hjelmn committed Dec 15, 2018
    …d IOReturn.
    
    - Replace all kern_return_t with IOReturn, they are basically the same, but IOReturn is more common in IOUSBLib
    - improve consistency by using the name 'kresult' for all IOReturn-type results, and not using that name for libusb_error return values.
    - changed a few functions to use real 'bool' (this file already uses C99)
    - replaced some raw '0's with LIBUSB_SUCCESS or kIOReturnSuccess.
    - replaced some raw 'int's with either IOReturn or enum libusb_error.
    - replaced ambiguous "if (kresult)" with more explicit "if (kresult != kIOReturnSuccess)"
    - replaced incorrect use of darwin_to_libusb with darwin_transfer_status
    
    Most of these were found by increasing the compiler warning level.
    
    Closes #510
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  10. Removed unneeded checks for passing null to free()

    seanm authored and hjelmn committed Dec 15, 2018
    Closes #507
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  11. Added USBI_PRINTFLIKE to allow finding printf format string mistakes

    seanm authored and hjelmn committed Dec 15, 2018
    Fixed one such misktake
    
    Closes #506
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  12. use travis homebrew addon for reliability

    stephengroat authored and hjelmn committed Dec 17, 2018
    Closes #513
    
    Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Commits on Dec 5, 2018
  1. Bump libusb API version for next release

    hjelmn committed Dec 5, 2018
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  2. configure.ac: bump .so version for next release

    hjelmn committed Dec 5, 2018
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  3. Update ChangeLog

    hjelmn committed Dec 5, 2018
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  4. usbi_dbg() uses backend's clock_gettime(), break recursion in sunos b…

    pyhalov authored and hjelmn committed May 24, 2018
    …ackend
    
    Closes #431
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  5. examples: Fix format-truncation on debug

    victortoso authored and hjelmn committed Aug 7, 2018
    As description is used only for debug, we can extend it to be sure to
    fit 256 from string variable plus 3 chars from " - " as described in
    gcc warning below
    
     | testlibusb.c: In function ‘print_device.constprop’:
     | testlibusb.c:188:51: warning: ‘ - ’ directive output may be truncated writing 3 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
     |      snprintf(description, sizeof(description), "%s - ", string);
     |                                                    ^~~
     | testlibusb.c:188:5: note: ‘snprintf’ output between 4 and 259 bytes into a destination of size 256
     |      snprintf(description, sizeof(description), "%s - ", string);
     |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Closes #460
    
    Signed-off-by: Victor Toso <victortoso@redhat.com>
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  6. Enable timerfd on sunos when available

    pyhalov authored and hjelmn committed May 24, 2018
    Closes #432
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  7. Add missing libusb_exit on an error condition

    gudenau authored and hjelmn committed Jun 20, 2018
    Closes #448
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  8. Hungarian translation

    bence98 authored and hjelmn committed Nov 7, 2018
    Closes #493
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  9. Fixed typo in the documentation

    saur0n authored and hjelmn committed Nov 27, 2018
    Closes #496
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  10. core: new API libusb_set_log_cb() to redirect global and per context …

    dmitrykos authored and hjelmn committed Oct 23, 2018
    …log messages to the provided log handling function
    
    Closes #486
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Commits on Oct 22, 2018
  1. update nano

    hjelmn committed Oct 22, 2018
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  2. Add German translation

    alexander255 authored and hjelmn committed Jun 18, 2018
    Most strings were copied from the german `strerror` output on equivallent `errno` values and then adapted as necessary.
    
    Closes #446
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
  3. configure.ac: fix detection of clock_gettime library

    baruchsiach authored and hjelmn committed Jun 5, 2018
    glibc before 2.17 requires link with librt for clock_gettime(). The
    AC_SEARCH_LIBS check in configure.ac should detect this dependency.
    Unfortunately commit cb77a25 (configure.ac: Remove obsolete AC_ERROR
    and make formatting consistent) inadvertently renamed to clock_gettime2,
    thus breaking librt detection.
    
    Restore the correct clock_gettime() name.
    
    Closes #439
    
    Signed-off-by: Baruch Siach <baruch@tkos.co.il>
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Commits on Oct 17, 2018
  1. os/darwin: remove code that changed the device class used

    hjelmn committed Oct 17, 2018
    To support macOS El Capitan I added some code to change from using the
    IOUSBDevice class to using IOUSBHostDevice. This looked necessary as
    Apple had re-writed IOUSBFamily and IOUSBHostDevice was the new base
    class name. The problem is that using the new class misses some
    devices in more recent versions of macOS. Apple is still including the
    IOClassNameOverride property (as of macOS Mojave) so it is still safe
    to search using the IOUSBDevice class. We will need to find a
    different class if Apple ever removes the IOClassNameOverride
    property from USB devices.
    
    Closes #428
    
    Signed-off-by: Nathan Hjelm <hjelmn@mac.com>
Commits on Jul 26, 2018
  1. os/darwin: switch from using ResetDevice to USBDeviceReEnumerate

    hjelmn committed Jul 26, 2018
    In newer versions of macOS the ResetDevice function does nothing. For
    these systems we have to use USBDeviceReEnumerate. This should also
    work for older versions os MacOS X.
    
    Fixes #455
    
    Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Commits on Jul 9, 2018
  1. Move to brew bundle

    stephengroat authored and hjelmn committed Mar 30, 2018
    improved dependency management with brew bundle