diff options
author | Pete Batard <pbatard@gmail.com> | 2010-10-05 19:52:19 +0100 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-10-05 19:52:19 +0100 |
commit | 036f2c9ff946f54cbeb01e06de954aecc6934a11 (patch) | |
tree | d5c956f45c312bfe05cf5ad222f84c95259db708 | |
parent | 95ff145cbd1d972baaab29b2782c6aae47829a6e (diff) | |
download | libusb-036f2c9ff946f54cbeb01e06de954aecc6934a11.tar.gz |
merged pbr309
-rw-r--r-- | configure.ac | 34 | ||||
-rw-r--r-- | libusb-1.0.pc.in | 1 | ||||
-rw-r--r-- | libusb/Makefile.am | 1 | ||||
-rw-r--r-- | libusb/os/linux_usbfs.c | 11 | ||||
-rw-r--r-- | libusb/os/poll_windows.c | 140 | ||||
-rw-r--r-- | libusb/os/windows_usb.c | 44 | ||||
-rw-r--r-- | libusb/os/windows_usb.h | 2 |
7 files changed, 123 insertions, 110 deletions
diff --git a/configure.ac b/configure.ac index bfe2f2d..bf0e3a1 100644 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,17 @@ AC_SUBST([LIBUSB_VERSION_MINOR], [LIBUSB_MINOR]) AC_SUBST([LIBUSB_VERSION_MICRO], [LIBUSB_MICRO]) AC_SUBST([LIBUSB_VERSION_NANO], [LIBUSB_NANO]) +# Library versioning +# These numbers should be tweaked on every release. Read carefully: +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +# http://sourceware.org/autobook/autobook/autobook_91.html +lt_current="1" +lt_revision="0" +lt_age="1" +AC_SUBST(lt_current) +AC_SUBST(lt_revision) +AC_SUBST(lt_age) + AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([libusb/core.c]) AC_CONFIG_MACRO_DIR([m4]) @@ -26,6 +37,7 @@ AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions]) AM_MAINTAINER_MODE AC_MSG_CHECKING([operating system]) +PC_LIBS_PRIVATE= case $host in *-linux*) AC_DEFINE(OS_LINUX, [], [Linux backend]) @@ -33,9 +45,11 @@ case $host in AC_DEFINE([THREADS_POSIX], [], [Use Posix Threads]) AC_MSG_RESULT([Linux]) backend="linux" - AC_CHECK_LIB(rt, clock_gettime) + AC_CHECK_LIB(rt, clock_gettime, PC_LIBS_PRIVATE="-lrt") + LIBS="${LIBS} ${PC_LIBS_PRIVATE}" threads="posix" THREAD_CFLAGS="-pthread" + PC_LIBS_PRIVATE="${PC_LIBS_PRIVATE} -pthread" AM_CFLAGS="-std=gnu99" AM_LDFLAGS="" ;; @@ -49,7 +63,8 @@ case $host in threads="posix" THREAD_CFLAGS="-pthread" AM_CFLAGS="-std=gnu99" - AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined" + PC_LIBS_PRIVATE="-Wl,-framework,IOKit -Wl,-framework,CoreFoundation -Wl,-prebind -no-undefined -pthread" + AM_LDFLAGS=${PC_LIBS_PRIVATE} ;; *-mingw*) AC_DEFINE(OS_WINDOWS, [], [Windows backend]) @@ -58,7 +73,8 @@ case $host in backend="windows" threads="windows" create_import_lib="yes" - LIBS="-lsetupapi -lole32 -ladvapi32" + PC_LIBS_PRIVATE="-lsetupapi -lole32 -ladvapi32" + LIBS="${LIBS} ${PC_LIBS_PRIVATE}" # -avoid-version to avoid a naming scheme such as libusb-0.dll AM_LDFLAGS="-no-undefined -avoid-version -Wl,--add-stdcall-alias" AM_CFLAGS="-std=c99" @@ -72,7 +88,8 @@ case $host in AC_MSG_RESULT([Windows]) backend="windows" threads="posix" - LIBS="-lsetupapi -lole32 -ladvapi32" + PC_LIBS_PRIVATE="-lsetupapi -lole32 -ladvapi32" + LIBS="${LIBS} ${PC_LIBS_PRIVATE}" AM_CFLAGS="-std=c99" AM_LDFLAGS="-no-undefined -avoid-version" AC_CHECK_TOOL(RC, windres, no) @@ -80,6 +97,7 @@ case $host in *) AC_MSG_ERROR([unsupported operating system]) esac +AC_SUBST(PC_LIBS_PRIVATE) AM_CONDITIONAL([OS_LINUX], [test "x$backend" = "xlinux"]) AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = "xdarwin"]) @@ -87,14 +105,6 @@ AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = "xwindows"]) AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" = "xposix"]) AM_CONDITIONAL([CREATE_IMPORT_LIB], [test "x$create_import_lib" = "xyes"]) -# Library versioning -lt_major="0" -lt_revision="0" -lt_age="0" -AC_SUBST(lt_major) -AC_SUBST(lt_revision) -AC_SUBST(lt_age) - # timerfd AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0]) AC_ARG_ENABLE([timerfd], diff --git a/libusb-1.0.pc.in b/libusb-1.0.pc.in index dd6bde0..0abb16b 100644 --- a/libusb-1.0.pc.in +++ b/libusb-1.0.pc.in @@ -7,5 +7,6 @@ Name: libusb-1.0 Description: C API for USB device access from Linux userspace Version: @VERSION@ Libs: -L${libdir} -lusb-1.0 +Libs.private: @PC_LIBS_PRIVATE@ Cflags: -I${includedir}/libusb-1.0 diff --git a/libusb/Makefile.am b/libusb/Makefile.am index 60ab752..38e196a 100644 --- a/libusb/Makefile.am +++ b/libusb/Makefile.am @@ -34,6 +34,7 @@ endif endif libusb_1_0_la_CFLAGS = $(VISIBILITY_CFLAGS) $(AM_CFLAGS) $(THREAD_CFLAGS) +libusb_1_0_la_LDFLAGS = -version-info $(lt_current):$(lt_revision):$(lt_age) libusb_1_0_la_SOURCES = libusbi.h core.c descriptor.c io.c sync.c $(OS_SRC) \ os/linux_usbfs.h os/darwin_usb.h os/windows_usb.h \ os/threads_posix.h os/threads_windows.h \ diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index ed1ce13..0c6ed95 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -201,15 +201,16 @@ static clockid_t find_monotonic_clock(void) struct timespec ts; int r; +#ifdef CLOCK_MONOTONIC /* Linux 2.6.28 adds CLOCK_MONOTONIC_RAW but we don't use it * because it's not available through timerfd */ r = clock_gettime(CLOCK_MONOTONIC, &ts); - if (r == 0) { + if (r == 0) return CLOCK_MONOTONIC; - } else { - usbi_dbg("monotonic clock doesn't work, errno %d", errno); - return CLOCK_REALTIME; - } + usbi_dbg("monotonic clock doesn't work, errno %d", errno); +#endif + + return CLOCK_REALTIME; } /* bulk continuation URB flag available from Linux 2.6.32 */ diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index 8656ea0..370d61e 100644 --- a/libusb/os/poll_windows.c +++ b/libusb/os/poll_windows.c @@ -138,21 +138,21 @@ static volatile LONG compat_spinlock = 0; // platform headers, we hook into the Kernel32 system DLL directly to seek it. static BOOL (__stdcall *pCancelIoEx)(HANDLE, LPOVERLAPPED) = NULL; #define CancelIoEx_Available (pCancelIoEx != NULL) -__inline BOOL cancel_io(int index) +__inline BOOL cancel_io(int _index) { - if ((index < 0) || (index >= MAX_FDS)) { + if ((_index < 0) || (_index >= MAX_FDS)) { return FALSE; } - if ( (poll_fd[index].fd < 0) || (poll_fd[index].handle == INVALID_HANDLE_VALUE) - || (poll_fd[index].handle == 0) || (poll_fd[index].overlapped == NULL) ) { + if ( (poll_fd[_index].fd < 0) || (poll_fd[_index].handle == INVALID_HANDLE_VALUE) + || (poll_fd[_index].handle == 0) || (poll_fd[_index].overlapped == NULL) ) { return TRUE; } if (CancelIoEx_Available) { - return (*pCancelIoEx)(poll_fd[index].handle, poll_fd[index].overlapped); + return (*pCancelIoEx)(poll_fd[_index].handle, poll_fd[_index].overlapped); } - if (_poll_fd[index].thread_id == GetCurrentThreadId()) { - return CancelIo(poll_fd[index].handle); + if (_poll_fd[_index].thread_id == GetCurrentThreadId()) { + return CancelIo(poll_fd[_index].handle); } usbi_warn(NULL, "Unable to cancel I/O that was started from another thread"); return FALSE; @@ -457,25 +457,25 @@ struct winfd usbi_create_fd(HANDLE handle, int access_mode) return INVALID_WINFD; } -void _free_index(int index) +void _free_index(int _index) { // Cancel any async IO (Don't care about the validity of our handles for this) - cancel_io(index); + cancel_io(_index); // close fake handle for devices - if ( (poll_fd[index].handle != INVALID_HANDLE_VALUE) && (poll_fd[index].handle != 0) - && (GetFileType(poll_fd[index].handle) == FILE_TYPE_UNKNOWN) ) { - _close(poll_fd[index].fd); + if ( (poll_fd[_index].handle != INVALID_HANDLE_VALUE) && (poll_fd[_index].handle != 0) + && (GetFileType(poll_fd[_index].handle) == FILE_TYPE_UNKNOWN) ) { + _close(poll_fd[_index].fd); } // close the duplicate handle (if we have an actual duplicate) if (!CancelIoEx_Available) { - if (_poll_fd[index].original_handle != INVALID_HANDLE_VALUE) { - CloseHandle(poll_fd[index].handle); + if (_poll_fd[_index].original_handle != INVALID_HANDLE_VALUE) { + CloseHandle(poll_fd[_index].handle); } - _poll_fd[index].original_handle = INVALID_HANDLE_VALUE; - _poll_fd[index].thread_id = 0; + _poll_fd[_index].original_handle = INVALID_HANDLE_VALUE; + _poll_fd[_index].thread_id = 0; } - free_overlapped(poll_fd[index].overlapped); - poll_fd[index] = INVALID_WINFD; + free_overlapped(poll_fd[_index].overlapped); + poll_fd[_index] = INVALID_WINFD; } /* @@ -485,16 +485,16 @@ void _free_index(int index) */ void usbi_free_fd(int fd) { - int index; + int _index; CHECK_INIT_POLLING; - index = _fd_to_index_and_lock(fd); - if (index < 0) { + _index = _fd_to_index_and_lock(fd); + if (_index < 0) { return; } - _free_index(index); - LeaveCriticalSection(&_poll_fd[index].mutex); + _free_index(_index); + LeaveCriticalSection(&_poll_fd[_index].mutex); } /* @@ -586,7 +586,7 @@ struct winfd overlapped_to_winfd(OVERLAPPED* overlapped) int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout) { unsigned i; - int index, object_index, triggered; + int _index, object_index, triggered; HANDLE *handles_to_wait_on; int *handle_to_index; DWORD nb_handles_to_wait_on = 0; @@ -630,15 +630,15 @@ int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout) goto poll_exit; } - index = _fd_to_index_and_lock(fds[i].fd); - poll_dbg("fd[%d]=%d: (overlapped=%p) got events %04X", i, poll_fd[index].fd, poll_fd[index].overlapped, fds[i].events); + _index = _fd_to_index_and_lock(fds[i].fd); + poll_dbg("fd[%d]=%d: (overlapped=%p) got events %04X", i, poll_fd[_index].fd, poll_fd[_index].overlapped, fds[i].events); - if ( (index < 0) || (poll_fd[index].handle == INVALID_HANDLE_VALUE) - || (poll_fd[index].handle == 0) || (poll_fd[index].overlapped == NULL)) { + if ( (_index < 0) || (poll_fd[_index].handle == INVALID_HANDLE_VALUE) + || (poll_fd[_index].handle == 0) || (poll_fd[_index].overlapped == NULL)) { fds[i].revents |= POLLNVAL | POLLERR; errno = EBADF; - if (index >= 0) { - LeaveCriticalSection(&_poll_fd[index].mutex); + if (_index >= 0) { + LeaveCriticalSection(&_poll_fd[_index].mutex); } usbi_warn(NULL, "invalid fd"); triggered = -1; @@ -646,33 +646,33 @@ int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout) } // IN or OUT must match our fd direction - if ((fds[i].events & POLLIN) && (poll_fd[index].rw != RW_READ)) { + if ((fds[i].events & POLLIN) && (poll_fd[_index].rw != RW_READ)) { fds[i].revents |= POLLNVAL | POLLERR; errno = EBADF; usbi_warn(NULL, "attempted POLLIN on fd without READ access"); - LeaveCriticalSection(&_poll_fd[index].mutex); + LeaveCriticalSection(&_poll_fd[_index].mutex); triggered = -1; goto poll_exit; } - if ((fds[i].events & POLLOUT) && (poll_fd[index].rw != RW_WRITE)) { + if ((fds[i].events & POLLOUT) && (poll_fd[_index].rw != RW_WRITE)) { fds[i].revents |= POLLNVAL | POLLERR; errno = EBADF; usbi_warn(NULL, "attempted POLLOUT on fd without WRITE access"); - LeaveCriticalSection(&_poll_fd[index].mutex); + LeaveCriticalSection(&_poll_fd[_index].mutex); triggered = -1; goto poll_exit; } // The following macro only works if overlapped I/O was reported pending - if ( (HasOverlappedIoCompleted(poll_fd[index].overlapped)) - || (HasOverlappedIoCompletedSync(poll_fd[index].overlapped)) ) { + if ( (HasOverlappedIoCompleted(poll_fd[_index].overlapped)) + || (HasOverlappedIoCompletedSync(poll_fd[_index].overlapped)) ) { poll_dbg(" completed"); // checks above should ensure this works: fds[i].revents = fds[i].events; triggered++; } else { - handles_to_wait_on[nb_handles_to_wait_on] = poll_fd[index].overlapped->hEvent; + handles_to_wait_on[nb_handles_to_wait_on] = poll_fd[_index].overlapped->hEvent; handle_to_index[nb_handles_to_wait_on] = i; #if defined(DYNAMIC_FDS) // If this fd from the poll set is also part of the new_fd event handle table, remove it @@ -687,7 +687,7 @@ int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout) #endif nb_handles_to_wait_on++; } - LeaveCriticalSection(&_poll_fd[index].mutex); + LeaveCriticalSection(&_poll_fd[_index].mutex); } #if defined(DYNAMIC_FDS) // At this stage, new_fd[] should only contain events from fds that @@ -738,11 +738,11 @@ int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout) #endif poll_dbg(" completed after wait"); i = handle_to_index[object_index]; - index = _fd_to_index_and_lock(fds[i].fd); + _index = _fd_to_index_and_lock(fds[i].fd); fds[i].revents = fds[i].events; triggered++; - if (index >= 0) { - LeaveCriticalSection(&_poll_fd[index].mutex); + if (_index >= 0) { + LeaveCriticalSection(&_poll_fd[_index].mutex); } } else if (ret == WAIT_TIMEOUT) { poll_dbg(" timed out"); @@ -773,28 +773,28 @@ poll_exit: */ int usbi_close(int fd) { - int index; + int _index; int r = -1; CHECK_INIT_POLLING; - index = _fd_to_index_and_lock(fd); + _index = _fd_to_index_and_lock(fd); - if (index < 0) { + if (_index < 0) { errno = EBADF; } else { - if (poll_fd[index].overlapped != NULL) { + if (poll_fd[_index].overlapped != NULL) { // Must be a different event for each end of the pipe - CloseHandle(poll_fd[index].overlapped->hEvent); - free(poll_fd[index].overlapped); + CloseHandle(poll_fd[_index].overlapped->hEvent); + free(poll_fd[_index].overlapped); } - if (CloseHandle(poll_fd[index].handle) == 0) { + if (CloseHandle(poll_fd[_index].handle) == 0) { errno = EIO; } else { r = 0; } - poll_fd[index] = INVALID_WINFD; - LeaveCriticalSection(&_poll_fd[index].mutex); + poll_fd[_index] = INVALID_WINFD; + LeaveCriticalSection(&_poll_fd[_index].mutex); } return r; } @@ -804,7 +804,7 @@ int usbi_close(int fd) */ ssize_t usbi_write(int fd, const void *buf, size_t count) { - int index; + int _index; CHECK_INIT_POLLING; @@ -813,24 +813,24 @@ ssize_t usbi_write(int fd, const void *buf, size_t count) return -1; } - index = _fd_to_index_and_lock(fd); + _index = _fd_to_index_and_lock(fd); - if ( (index < 0) || (poll_fd[index].overlapped == NULL) ) { + if ( (_index < 0) || (poll_fd[_index].overlapped == NULL) ) { errno = EBADF; - if (index >= 0) { - LeaveCriticalSection(&_poll_fd[index].mutex); + if (_index >= 0) { + LeaveCriticalSection(&_poll_fd[_index].mutex); } return -1; } - poll_dbg("set pipe event (fd = %d, thread = %08X)", index, GetCurrentThreadId()); - SetEvent(poll_fd[index].overlapped->hEvent); - poll_fd[index].overlapped->Internal = STATUS_WAIT_0; + poll_dbg("set pipe event (fd = %d, thread = %08X)", _index, GetCurrentThreadId()); + SetEvent(poll_fd[_index].overlapped->hEvent); + poll_fd[_index].overlapped->Internal = STATUS_WAIT_0; // If two threads write on the pipe at the same time, we need to // process two separate reads => use the overlapped as a counter - poll_fd[index].overlapped->InternalHigh++; + poll_fd[_index].overlapped->InternalHigh++; - LeaveCriticalSection(&_poll_fd[index].mutex); + LeaveCriticalSection(&_poll_fd[_index].mutex); return sizeof(unsigned char); } @@ -839,7 +839,7 @@ ssize_t usbi_write(int fd, const void *buf, size_t count) */ ssize_t usbi_read(int fd, void *buf, size_t count) { - int index; + int _index; ssize_t r = -1; CHECK_INIT_POLLING; @@ -849,30 +849,30 @@ ssize_t usbi_read(int fd, void *buf, size_t count) return -1; } - index = _fd_to_index_and_lock(fd); + _index = _fd_to_index_and_lock(fd); - if (index < 0) { + if (_index < 0) { errno = EBADF; return -1; } - if (WaitForSingleObject(poll_fd[index].overlapped->hEvent, INFINITE) != WAIT_OBJECT_0) { + if (WaitForSingleObject(poll_fd[_index].overlapped->hEvent, INFINITE) != WAIT_OBJECT_0) { usbi_warn(NULL, "waiting for event failed: %d", (int)GetLastError()); errno = EIO; goto out; } - poll_dbg("clr pipe event (fd = %d, thread = %08X)", index, GetCurrentThreadId()); - poll_fd[index].overlapped->InternalHigh--; + poll_dbg("clr pipe event (fd = %d, thread = %08X)", _index, GetCurrentThreadId()); + poll_fd[_index].overlapped->InternalHigh--; // Don't reset unless we don't have any more events to process - if (poll_fd[index].overlapped->InternalHigh <= 0) { - ResetEvent(poll_fd[index].overlapped->hEvent); - poll_fd[index].overlapped->Internal = STATUS_PENDING; + if (poll_fd[_index].overlapped->InternalHigh <= 0) { + ResetEvent(poll_fd[_index].overlapped->hEvent); + poll_fd[_index].overlapped->Internal = STATUS_PENDING; } r = sizeof(unsigned char); out: - LeaveCriticalSection(&_poll_fd[index].mutex); + LeaveCriticalSection(&_poll_fd[_index].mutex); return r; } diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index bf94603..4c91bca 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -282,9 +282,9 @@ static int Cfgmgr32_init(void) * incremented index starting at zero) until all interfaces have been returned. */ bool get_devinfo_data(struct libusb_context *ctx, - HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, unsigned index) + HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, unsigned _index) { - if (index <= 0) { + if (_index <= 0) { *dev_info = SetupDiGetClassDevs(NULL, "USB", NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES); if (*dev_info == INVALID_HANDLE_VALUE) { return false; @@ -292,10 +292,10 @@ bool get_devinfo_data(struct libusb_context *ctx, } dev_info_data->cbSize = sizeof(SP_DEVINFO_DATA); - if (!SetupDiEnumDeviceInfo(*dev_info, index, dev_info_data)) { + if (!SetupDiEnumDeviceInfo(*dev_info, _index, dev_info_data)) { if (GetLastError() != ERROR_NO_MORE_ITEMS) { usbi_err(ctx, "Could not obtain device info data for index %u: %s", - index, windows_error_str(0)); + _index, windows_error_str(0)); } SetupDiDestroyDeviceInfoList(*dev_info); *dev_info = INVALID_HANDLE_VALUE; @@ -318,22 +318,22 @@ bool get_devinfo_data(struct libusb_context *ctx, * incremented index starting at zero) until all interfaces have been returned. */ SP_DEVICE_INTERFACE_DETAIL_DATA *get_interface_details(struct libusb_context *ctx, - HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, const GUID* guid, unsigned index) + HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, const GUID* guid, unsigned _index) { SP_DEVICE_INTERFACE_DATA dev_interface_data; SP_DEVICE_INTERFACE_DETAIL_DATA *dev_interface_details = NULL; DWORD size; - if (index <= 0) { + if (_index <= 0) { *dev_info = SetupDiGetClassDevs(guid, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE); } if (dev_info_data != NULL) { dev_info_data->cbSize = sizeof(SP_DEVINFO_DATA); - if (!SetupDiEnumDeviceInfo(*dev_info, index, dev_info_data)) { + if (!SetupDiEnumDeviceInfo(*dev_info, _index, dev_info_data)) { if (GetLastError() != ERROR_NO_MORE_ITEMS) { usbi_err(ctx, "Could not obtain device info data for index %u: %s", - index, windows_error_str(0)); + _index, windows_error_str(0)); } SetupDiDestroyDeviceInfoList(*dev_info); *dev_info = INVALID_HANDLE_VALUE; @@ -342,10 +342,10 @@ SP_DEVICE_INTERFACE_DETAIL_DATA *get_interface_details(struct libusb_context *ct } dev_interface_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); - if (!SetupDiEnumDeviceInterfaces(*dev_info, NULL, guid, index, &dev_interface_data)) { + if (!SetupDiEnumDeviceInterfaces(*dev_info, NULL, guid, _index, &dev_interface_data)) { if (GetLastError() != ERROR_NO_MORE_ITEMS) { usbi_err(ctx, "Could not obtain interface data for index %u: %s", - index, windows_error_str(0)); + _index, windows_error_str(0)); } SetupDiDestroyDeviceInfoList(*dev_info); *dev_info = INVALID_HANDLE_VALUE; @@ -357,7 +357,7 @@ SP_DEVICE_INTERFACE_DETAIL_DATA *get_interface_details(struct libusb_context *ct // The dummy call should fail with ERROR_INSUFFICIENT_BUFFER if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { usbi_err(ctx, "could not access interface data (dummy) for index %u: %s", - index, windows_error_str(0)); + _index, windows_error_str(0)); goto err_exit; } } else { @@ -366,7 +366,7 @@ SP_DEVICE_INTERFACE_DETAIL_DATA *get_interface_details(struct libusb_context *ct } if ((dev_interface_details = malloc(size)) == NULL) { - usbi_err(ctx, "could not allocate interface data for index %u.", index); + usbi_err(ctx, "could not allocate interface data for index %u.", _index); goto err_exit; } @@ -374,7 +374,7 @@ SP_DEVICE_INTERFACE_DETAIL_DATA *get_interface_details(struct libusb_context *ct if (!SetupDiGetDeviceInterfaceDetail(*dev_info, &dev_interface_data, dev_interface_details, size, &size, NULL)) { usbi_err(ctx, "could not access interface data (actual) for index %u: %s", - index, windows_error_str(0)); + _index, windows_error_str(0)); } return dev_interface_details; @@ -2914,7 +2914,7 @@ static int _hid_get_config_descriptor(struct hid_device_priv* dev, void *data, s return LIBUSB_COMPLETED; } -static int _hid_get_string_descriptor(struct hid_device_priv* dev, int index, +static int _hid_get_string_descriptor(struct hid_device_priv* dev, int _index, void *data, size_t *size) { void *tmp = NULL; @@ -2931,12 +2931,12 @@ static int _hid_get_string_descriptor(struct hid_device_priv* dev, int index, return LIBUSB_ERROR_OVERFLOW; } - if (index == 0) { + if (_index == 0) { tmp = string_langid; tmp_size = sizeof(string_langid)+2; } else { for (i=0; i<3; i++) { - if (index == (dev->string_index[i])) { + if (_index == (dev->string_index[i])) { tmp = dev->string[i]; tmp_size = (_hid_wcslen(dev->string[i])+1) * sizeof(WCHAR); break; @@ -3050,7 +3050,7 @@ static int _hid_get_report_descriptor(struct hid_device_priv* dev, void *data, s } static int _hid_get_descriptor(struct hid_device_priv* dev, HANDLE hid_handle, int recipient, - int type, int index, void *data, size_t *size) + int type, int _index, void *data, size_t *size) { switch(type) { case LIBUSB_DT_DEVICE: @@ -3058,20 +3058,20 @@ static int _hid_get_descriptor(struct hid_device_priv* dev, HANDLE hid_handle, i return _hid_get_device_descriptor(dev, data, size); case LIBUSB_DT_CONFIG: usbi_dbg("LIBUSB_DT_CONFIG"); - if (!index) + if (!_index) return _hid_get_config_descriptor(dev, data, size); return LIBUSB_ERROR_INVALID_PARAM; case LIBUSB_DT_STRING: usbi_dbg("LIBUSB_DT_STRING"); - return _hid_get_string_descriptor(dev, index, data, size); + return _hid_get_string_descriptor(dev, _index, data, size); case LIBUSB_DT_HID: usbi_dbg("LIBUSB_DT_HID"); - if (!index) + if (!_index) return _hid_get_hid_descriptor(dev, data, size); return LIBUSB_ERROR_INVALID_PARAM; case LIBUSB_DT_REPORT: usbi_dbg("LIBUSB_DT_REPORT"); - if (!index) + if (!_index) return _hid_get_report_descriptor(dev, data, size); return LIBUSB_ERROR_INVALID_PARAM; case LIBUSB_DT_PHYSICAL: @@ -3243,7 +3243,7 @@ static int _hid_set_report(struct hid_device_priv* dev, HANDLE hid_handle, int i } static int _hid_class_request(struct hid_device_priv* dev, HANDLE hid_handle, int request_type, - int request, int value, int index, void *data, struct windows_transfer_priv *tp, + int request, int value, int _index, void *data, struct windows_transfer_priv *tp, size_t *size, OVERLAPPED* overlapped) { int report_type = (value >> 8) & 0xFF; diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h index 4b708cc..e8ab43d 100644 --- a/libusb/os/windows_usb.h +++ b/libusb/os/windows_usb.h @@ -69,7 +69,7 @@ extern char *_strdup(const char *strSource); #define safe_strlen(str) ((str==NULL)?0:strlen(str)) #define safe_sprintf _snprintf #define safe_unref_device(dev) do {if (dev != NULL) {libusb_unref_device(dev); dev = NULL;}} while(0) -#define wchar_to_utf8_ms(wstr, str, len) WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL) +#define wchar_to_utf8_ms(wstr, str, strlen) WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, strlen, NULL, NULL) inline void upperize(char* str) { size_t i; if (str == NULL) return; |