Patched with '0001-Linux-Fix-70-race-condition-insysfs_get_device_list.patch'
Windows: Don't use a log function body macro for old MS compilers

The duplication is a lot more straightforward than the previous LOG_BODY
macro, which also didn't handle the special debug case correctly. The
duplicated code is fortunately not very long.
Windows: Fix build on VC++2003 which doesn't support variadic macros

Change _MSC_VER tests to check for >= 1400 instead of > 1200 because
Visual C++ did not support variadic macros until VC++2005, as per
http://msdn.microsoft.com/en-us/library/ms177415%28v=VS.80%29.aspx

Since usbi_dbg() is a function and not a macro with the old MS C
compilers the functions guid_to_string() and windows_error_str()
need to be compiled unconditionally, and the compiler should remove
the dead code when debug logging is disabled on newer compilers.
Updated CFLAGS for easier valgrind debugging
OpenBSD: Fix warning: 'hpriv' may be used uninitialized

As reported in http://marc.info/?m=133376187514495

The variable would be used uninitialized when the internal list of
open devices is empty as obsd_handle_events() checks which device
the event fd belongs to, which can not actually happen, but if it
ever does happen then we will now return LIBUSB_ERROR_NO_DEVICE.

Reported-by: Xiaofan Chen <xiaofanc@gmail.com>
examples: Use snprintf() instead of sprintf() in dpfp and dpfp_threaded

The OpenBSD C compiler generates a warning for every use of sprintf()
and for a good reason. Reported in http://marc.info/?m=133376187514495

Reported-by: Xiaofan Chen <xiaofanc@gmail.com>
Linux: Silence unused variable warnings when without CLOCK_MONOTONIC

Signed-off-by: Xiaofan Chen <xiaofanc@gmail.com>
configure.ac: Separate per-OS backend selection from per-backend settings
Experimental support for NetBSD using the OpenBSD backend

Signed-off-by: Xiaofan Chen <xiaofanc@gmail.com>
io.c: Add debug message with the callback address on completed transfer
libusb-1.0.pc: Mention OpenBSD and NetBSD in description
Linux: Fix cancel_transfer return value when cancelling a multi-urb transfer

If we fail to cancel the last urb of a multi-urb transfer because it
has already completed (errno == EINVAL on DISCARD_URB), then the entire
transfer has already completed, so returning NOT_FOUND is consistent
with what the documentation for libusb_cancel_transfer() says.

But if we've successfully cancelled the last urb, and then another urb
fails with errno == EINVAL, this means that we've still cancelled the
transfer, as it has only *partially* completed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Don't print an error when libusb_cancel_transfer() fails with NOT_FOUND

As stated in the documentation for libusb_cancel_transfer(),
LIBUSB_ERROR_NOT_FOUND is an expected return value for
libusb_cancel_transfer() under certain circumstances, so
printing an error every time this happens is undesirable.

Even more so because under Linux IOCTL_USBFS_DISCARDURB sets errno
to EINVAL when the kernel can't not find the urb in the kernel's
urbs-in-flight list, which means that the urb has already completed
at the host controller level but it has not necessarily been reaped
yet. IOW under Linux libusb_cancel_transfer() may yield a result of
LIBUSB_ERROR_NOT_FOUND *before* the transfer's callback has been
called! In conclusion there is no way for applications to avoid
calling libusb_cancel_transfer() on already completed transfers,
and these errors can and do happen frequently for some USB traffic.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Linux: Fix URB return code handling

During testing of my usbredir code I hit a case where EOVERFLOW was not
handled in handle_control_completion(). Instead of just fixing this one
case I've audited (and fixed where necessary) all handle_foo_completion()
functions to know about all errors documented in
linux/Documentation/usb/error-codes.txt.

Note that for handle_iso_completion() this patch actually removes the
handling of some codes, since these can never occur on an iso urb (they
can only occur on the iso packets included in the urb, see the next patch
in this series). Also, in case an unknown status is encountered on an iso
urb this patch sets the urb's status to ERROR rather then leaving it at
completed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Linux: Translate isoc packet status codes to LIBUSB_TRANSFER_ codes

During testing of my usbredir code I hit a scenario where my libusb
app was seeing EXDEV as status in the transfer's iso_packet_desc.

This happened because we didn't translate linux negative errno errors
in each isoc packet's status to LIBUSB_TRANSFER_ status codes! This
patch adds these translations.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Linux: Remove bogus status handling from handle_iso_completion()

Remove a useless check+set of status because:
1. The check is always true; and
2. The new value is never used

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Linux: Fix a comment in handle_iso_completion()

Fix the comment at the end of handle_iso_completion, we don't stop on
urbs / isoc packets with less data then requested, which is a good
thing since it is a normal condition for isoc transfers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Windows: Bring .vcproj x86_64 output directories in line with x86_32

libusbx.git commit abdb4437ea1897226076fa706651e350dba1cfd5
configure.ac: LT_LANG([Windows Resource]) makes windres check redundant

libusbx.git commit 4f9fd6a29a712b0e3312983e9ff153e6d7ed0822
Windows: fix Clang warnings about unused assignations

libusbx.git commit c0e7b289fdb35687b90263b14426319d2b96b132