summaryrefslogtreecommitdiff
path: root/libusb/core.c
Commit message (Collapse)AuthorAgeFilesLines
* Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflictsbaserock/morphPete Batard2012-07-031-14/+14
| | | | | | | | | * The LOG_LEVEL_ enums, that were moved to the public API in 933a319469bcccc962031c989e39d9d1f44f2885 may conflict with applications/headers that also define their own LOG_LEVEL_ values internally. * As a matter of fact, as per Trac #31, this produces a conflict with libusb-compat, as it defines its own levels.
* Misc: Fix more Clang warnings in core and darwinPete Batard2012-07-021-1/+1
| | | | | | | | | | * http://sourceforge.net/mailarchive/message.php?msg_id=29418038 * core.c:700:4: warning: Function call argument is an uninitialized value * darwin_usb.c:1713:11: warning: Access to field 'cfSource' results in a dereference of a null pointer (loaded from variable 'hpriv') * sync.c/dpfp.c/dpfp_threaded.c: warning: Result of 'malloc' is converted to a pointer of type 'unsigned char', which is incompatible with sizeof operand type
* Windows: Address MSVC Level 4 & WDK's OACR/Prefast warningsPete Batard2012-07-021-16/+17
| | | | | | | | | | | | | * The library is now compiled with warning level 4 for VS2010 * Move silencing of 4200, 28125 and 28719 to msvc/config.h * Add fixes in core to silence unused variables warnings * Ensure that spinlock is always set interlocked in poll_windows * Add missing check for calloc return value * Fix data assignation in conditionals warnings * Fix an OACR/Prefast error related to the use of strncpy in xusb.c * Also fixes whitespace inconsistencies in core * Issues reported by Orin Eman and Xiaofan Chen. See: https://sourceforge.net/mailarchive/message.php?msg_id=29412656
* Windows: Fix warnings reported by the Intel CompilerPete Batard2012-06-251-6/+5
| | | | | | | | | * windows_usb.c(161): warning #181: argument is incompatible with corresponding format string conversion * windows_usb.c(2124): warning #111: statement is unreachable usbi_dbg("ERROR: broken timer thread"); * multiple: warning #188: enumerated type mixed with another * Issues reported by Orin Eman
* Core: Fix Clang warningsPete Batard2012-06-131-1/+2
| | | | | | | | | | | | | | | core.c: * Result of 'malloc' is converted to a pointer of type 'struct libusb_device *', which is incompatible with sizeof operand type 'void *' * Memory is never released; potential leak of memory pointed to by 'devs' * Assigned value is garbage or undefined (due to potentially empty and uninitialized device list) descriptor.c: * Function call argument is an uninitialized value io.c: * Call to 'malloc' has an allocation size of 0 bytes * Branch condition evaluates to a garbage value (due to get_next_timeout returning a negative error code instead of zero on error)
* All: Prevent memory leaks on realloc failuresPete Batard2012-06-081-1/+1
| | | | | | | | * p = realloc(p, new_size) does not free the original buffer in case of a realloc failure. * reallocf() can be used to do so, but is not available on all platforms. * This patch introduces usbi_reallocf() in libusbi.h and use that instead of realloc * Issue and original patch submitted by Moritz Lipp (trac #27)
* Core: Display libusbx version in libusb_init's debug outputPete Batard2012-06-071-1/+2
|
* Core: Add toggleable debug loggingPete Batard2012-06-041-1/+15
| | | | | * Also fix a missing space in debug log messages introduced with the previous timestamp logging update
* Core: Fix "LOG_LEVEL_NONE not handled in switch" warningLudovic Rousseau2012-06-041-1/+3
|
* Core: Send all logging output to stderrPete Batard2012-05-311-16/+11
| | | | * This effectively removes the use of stdout for info messages
* Core: Only display timestamps in debug mode and use init() as originPete Batard2012-05-281-10/+23
|
* Core: Define log levels in libusb.hPete Batard2012-05-281-14/+10
| | | | * Also update xusb sample to use these levels
* All: Add parent and port topology callsPete Batard2012-05-281-0/+64
| | | | | | * Adds libusb_get_port_number, libusb_get_parent and libusb_get_port_path * Linux implementation provided by Alan Stern, OS X by Nathan Hjelm * Unsupported for *BSD platforms
* Core: Add a timestamping and thread ID to loggingPeter Stuge2012-05-061-1/+68
|
* Core: update version struct for ABI compatibilityPete Batard2012-04-261-3/+4
| | | | | * Adds a static string for describe * Also update version documentation
* Core: Add get_version() callPete Batard2012-04-101-1/+13
| | | | * Also some formatting/typo improvements
* Misc: Rebrand to libusbxPete Batard2012-04-031-95/+68
| | | | | * Mentions of 'libusb' in doxygen are changed to 'libusbx' * Also update copyright notices and remove unneeded EOF LFs
* Add LIBUSB_TRANSFER_ADD_ZERO_PACKET flag to indicate need for ZLPPeter Stuge2012-02-221-0/+8
| | | | | | | | | | | | | | | Some protocols which use USB require an extra zero length data packet to signal end-of-transfer on bulk endpoints, if the last data packet is exactly wMaxPacketSize bytes long. This flag allows applications to inform libusb about this requirement, so that libusb can handle the issue transparently. At the moment the new flag is only supported on Linux, and submitting a transfer with the flag set returns an error at submit time on other systems. Hopefully implementations will soon follow for other systems. References #6.
* core.c: Fix clang warning about useless store to a variableSean McBride2012-02-081-2/+1
|
* OpenBSD backendMartin Pieuchot2012-01-301-0/+2
|
* Document that libusb_get_device_list() can return any libusb_error codePeter Stuge2011-10-171-2/+2
| | | | Fixes #87.
* Add libusb_error_name() API functionPeter Stuge2011-10-171-0/+44
| | | | | | | | | Until we have i18ned error messages we can at least offer easy translation from numeric error code to the error code's name. [hansg: switch() on enum to get a compiler warning if a case is missing] [hansg: Better return value when called with an unknown error code] [hansg: Fix DEFAULT_VISIBILITY in definition to compile on all platforms]
* Add libusb_has_capability() API functionPeter Stuge2011-10-171-0/+16
| | | | | | | | | Since it is currently not planned to change the filename of the libusb library between libusb-1.0 versions at least on Windows systems it's important to have a capability API. Currently there exists only one capability; LIBUSB_CAP_HAS_CAPABILITY, which tests support for the libusb_has_capability() API.
* Add debug message with libusb_open() error codePekka Nikander2011-09-221-0/+1
| | | | References #109.
* Fix #64 use of reserved identifiers throughout libusbNathan Hjelm2011-09-221-1/+1
|
* Allow devices with zero configurations to be discoveredPeter Stuge2011-09-151-4/+2
| | | | | | | | | | | | | At least in Linux, wireless USB devices have zero configurations until they have been authorized. This device state can be set for any USB device using: echo 0 > /sys/bus/usb/devices/?-?/authorized An unauthorized device would previously make usbi_sanitize_device() return LIBUSB_ERROR_IO, although there really was no I/O error. Reported-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
* Add new API function libusb_get_device_speed()Hans de Goede2011-09-151-0/+12
| | | | | | | | | | | | | | Reworked version of my earlier patch, largely modelled after (if not copy and pasted from) Trygve Laugstøl's <trygvis@inamo.no> similar commit 5a6541e0d80fb1f21e2b960bc2337a612f9d74fb in git://git.libusb.org/libusb-trygvis.git http://git.libusb.org/libusb-trygvis.git http://git.libusb.org/?p=libusb-trygvis.git;a=commitdiff;h=5a6541e0d This patch does not add any OS specific code. The supporting code in each backend follows in separate patches. References #45. Signed-off-By: Hans de Goede <hdegoede@redhat.com>
* Core: Use USB_MAXINTERFACES rather then sizeof(claimed_interfaces)Hans de Goede2011-07-241-3/+3
| | | | | | | | | claimed_interfaces is a long and thus its size differs on 32 versus 64 bits, this patch uses USB_MAXINTERFACES instead of sizeof(claimed_interfaces) on interface number range checks for consistent behavior independent of the arch. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Clean up in-flight transfers and device handle when closing a deviceVitali Lovich2011-07-241-0/+45
| | | | | | | | | | | | Any in-flight transfers should properly invalidate their references to device handles that are being closed. Additionally, they should be removed from the transfer-in-flight list. This is done with the events lock held to protect against another thread processing the same transfer. The events lock is initialized as a recursive mutex, because the device close code might itself be called while an event is being handled. Fixes #82. [stuge: Trivial rework to reduce indenting]
* Windows: enumeration overhaulPeter Stuge2011-06-131-1/+1
| | | | | | | | * uses multiple passes in a single call * uses a hash table, in anticipation for hotplug * adds a (dummy) HUB interface for harmonization * adds calloc on device struct creation in core (to detect and avoid unnecessary double initialization)
* Revert libusb_strerror() until we have i18n and l10nPeter Stuge2011-06-131-50/+0
|
* Updated documentation for unsupported Darwin/Windows callsPete Batard2010-09-191-1/+14
|
* Introduced calling convention (for Windows)Pete Batard2010-08-231-26/+31
| | | | | | | | | | | | | | | | | | Under Windows, a variety of compilers and configurations are available, meaning that the manner of parameter passing (e.g. registers vs stack) can vary. Match the Windows API calling convention and document this appropriately. This calling convention will be used regardless of the configuration of the user's development platform. The only user-level complication is that all functions used as libusb callbacks must use the same calling convention as libusb. The LIBUSB_CALL macro is provided to make this easy. Signed-off-by: Michael Plante <michael.plante@gmail.com> Signed-off-by: Pete Batard <pbatard@gmail.com> [dsd: slight change of strategy, add documentation]
* Add Windows supportPete Batard2010-07-271-2/+2
| | | | | | Via Cygwin/MinGW, libusb now has windows support. Thanks to contributors: Michael Plante, Orin Eman, Peter Stuge, Stephan Meyer, Xiaofan Chen.
* Only initialize the default context when it is requestedLudovic Rousseau2010-06-221-3/+3
|
* Fix 2 documentation typosLudovic Rousseau2010-06-101-2/+2
|
* Factorize event handler interruption codePete Batard2010-06-101-34/+45
| | | | | This will be additionally used by the windows backend which modifies the fd set frequently.
* Abstract low-level event handler operationsPete Batard2010-06-051-5/+4
| | | | | The Windows backend uses something other than UNIX file descriptors for event handling. Abstract out the operations to allow for this.
* Add reference counting to default contextDaniel Drake2010-05-311-12/+48
| | | | | | | | Michael Plante pointed out that if 2 users call libusb_init(NULL) within a process, we end up creating 2 default contexts, one of which is lost. Add reference counting so that the default context is reused and destroyed only after the last user.
* Fix libusb_init() error handlingDaniel Drake2010-05-271-3/+4
| | | | | | 9996ccaed7 introduced a problem in that mutexes could be destroyed in the error handling codepath before they had been created. Pointed out by Michael Plante.
* Modify log functions to compile with MSVC6Michael Plante2010-05-241-5/+12
| | | | MSVC6 does not support variadics.
* Add type parameter to the list_for_each_entry() and _safe() macrosPete Batard2010-05-201-1/+1
| | | | | typeof() is a GCC extension, not supported by target compilers such as MSVC.
* Rename all interface parameters to usb_interface or interface_numberPete Batard2010-05-181-12/+12
| | | | | | | | | | Remove the use of the ambiguous "interface" where possible without breaking the API. 'interface' is a preprocessor #define already associated with COM on Windows, that can cause a conflict as soon as windows.h is included. There are a few more places where interface is still used, which should be changed for libusb-2.0
* Stricter types and castsPete Batard2010-05-171-6/+6
|
* Fixes to error handling and exit codepathsPete Batard2010-05-171-2/+12
| | | | | | | Various locks and things were being leaked/left open when handling errors and during deinitialization. [dsd: small tweaks]
* Add libusb_strerror() to get short error message in English from enumFrancesco2010-05-121-0/+48
| | | | [dsd: small tweaks]
* Fix libusb_device::lock memory leakMichael Plante2010-05-121-0/+1
|
* Add internal abstraction for POSIX ThreadsPeter Stuge2010-05-121-42/+42
| | | | | | | | | | | | | | | | This prepares for a Windows backend without dependency on pthreads-w32. pthread_* is renamed to usbi_* and PTHREAD_* to USBI_*. A usbi_mutex_static_t and usbi_mutex_static_lock() and _unlock() are introduced for statically initialized mutexes, since they may be implemented using other types when pthreads mutexes aren't used. Move -pthread from libusb/Makefile.am to host-specific THREAD_CFLAGS in configure.ac. This will enable optional use of -lpthread for cygwin. [dsd: minor tweaks, and roll in a change based on patches from Pete Batard to only build dpfp_threaded example when we're using pthreads]
* Update documentation about early completion caveatsDaniel Drake2009-11-071-51/+40
|
* Linux: try harder not to lose any dataDaniel Drake2009-07-091-0/+56
| | | | | We would previously lose any data that was present on a cancelled URB. Work harder to make sure this doesn't happen.