diff options
author | Pete Batard <pbatard@gmail.com> | 2010-01-14 13:34:11 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-01-14 13:34:11 +0000 |
commit | 995c7df391d6011e624006bfbb610ace18f9488f (patch) | |
tree | 53c681c3a1dadd42eb3a536791076ad269d69f00 | |
parent | e45233574257f5ffd409e830c0d1d32fc6b37d81 (diff) | |
download | libusb-995c7df391d6011e624006bfbb610ace18f9488f.tar.gz |
fixed MSVC warnings (/W4 or MSVC6)
-rw-r--r-- | libusb/descriptor.c | 7 | ||||
-rw-r--r-- | libusb/libusb.h | 4 | ||||
-rw-r--r-- | libusb/os/windows_compat.h | 2 | ||||
-rw-r--r-- | libusb/os/windows_usb.c | 14 | ||||
-rw-r--r-- | libusb/os/windows_usb.h | 4 |
5 files changed, 18 insertions, 13 deletions
diff --git a/libusb/descriptor.c b/libusb/descriptor.c index acd7668..5664934 100644 --- a/libusb/descriptor.c +++ b/libusb/descriptor.c @@ -592,7 +592,7 @@ err: int usbi_get_config_index_by_value(struct libusb_device *dev, uint8_t bConfigurationValue, int *idx) { - int i; + uint8_t i; usbi_dbg("value %d", bConfigurationValue); for (i = 0; i < dev->num_configurations; i++) { @@ -639,7 +639,7 @@ API_EXPORTED int libusb_get_config_descriptor_by_value(libusb_device *dev, else if (idx == -1) return LIBUSB_ERROR_NOT_FOUND; else - return libusb_get_config_descriptor(dev, idx, config); + return libusb_get_config_descriptor(dev, (uint8_t)idx, config); } /** \ingroup desc @@ -676,7 +676,8 @@ API_EXPORTED int libusb_get_string_descriptor_ascii(libusb_device_handle *dev, uint8_t desc_index, unsigned char *data, int length) { unsigned char tbuf[255]; /* Some devices choke on size > 255 */ - int r, langid, si, di; + int r, si, di; + uint16_t langid; /* Asking for the zero'th index is special - it returns a string * descriptor that contains all the language IDs supported by the device. diff --git a/libusb/libusb.h b/libusb/libusb.h index 1fa01ac..46a5006 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -1146,7 +1146,7 @@ static inline int libusb_get_descriptor(libusb_device_handle *dev, { return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, LIBUSB_REQUEST_GET_DESCRIPTOR, (desc_type << 8) | desc_index, 0, data, - length, 1000); + (uint16_t) length, 1000); } /** \ingroup desc @@ -1168,7 +1168,7 @@ static inline int libusb_get_string_descriptor(libusb_device_handle *dev, { return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc_index, - langid, data, length, 1000); + langid, data, (uint16_t)length, 1000); } int libusb_get_string_descriptor_ascii(libusb_device_handle *dev, diff --git a/libusb/os/windows_compat.h b/libusb/os/windows_compat.h index 61de32d..4ce3645 100644 --- a/libusb/os/windows_compat.h +++ b/libusb/os/windows_compat.h @@ -48,7 +48,7 @@ #define POLLNVAL 0x0020 /* Invalid request: fd not open */ struct pollfd { - unsigned int fd; /* file descriptor */ + int fd; /* file descriptor */ short events; /* requested events */ short revents; /* returned events */ }; diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 2ec0970..fb14cd0 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -117,7 +117,7 @@ bool api_winusb_available = false; */ char* wchar_to_utf8(LPCWSTR wstr) { - size_t size; + int size; char* str; // Find out the size we need to allocate for our converted string @@ -201,7 +201,7 @@ static char* sanitize_path(const char* path) // Same goes for '\' and '#' after the root prefix. Ensure '#' is used for(j=root_size; j<size; j++) { - ret_path[j] = toupper(ret_path[j]); // Fix case too + ret_path[j] = (char)toupper(ret_path[j]); // Fix case too if (ret_path[j] == '\\') ret_path[j] = '#'; } @@ -1250,7 +1250,7 @@ static int windows_set_configuration(struct libusb_device_handle *dev_handle, in r = libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE, - LIBUSB_REQUEST_SET_CONFIGURATION, config, + LIBUSB_REQUEST_SET_CONFIGURATION, (uint16_t)config, 0, NULL, 0, 1000); return r; @@ -1798,7 +1798,7 @@ static int winusb_claim_interface(struct libusb_device_handle *dev_handle, int i return LIBUSB_ERROR_ACCESS; } - if (!WinUsb_GetAssociatedInterface(winusb_handle, iface-1, + if (!WinUsb_GetAssociatedInterface(winusb_handle, (UCHAR)iface-1, &handle_priv->interface_handle[iface].winusb)) { handle_priv->interface_handle[iface].winusb = INVALID_HANDLE_VALUE; switch(GetLastError()) { @@ -1998,13 +1998,17 @@ static int winusb_set_interface_altsetting(struct libusb_device_handle *dev_hand CHECK_WINUSB_AVAILABLE; + if (altsetting > 255) { + return LIBUSB_ERROR_INVALID_PARAM; + } + winusb_handle = handle_priv->interface_handle[iface].winusb; if ((winusb_handle == 0) || (winusb_handle == INVALID_HANDLE_VALUE)) { usbi_err(ctx, "interface must be claimed first"); return LIBUSB_ERROR_NOT_FOUND; } - if (!WinUsb_SetCurrentAlternateSetting(winusb_handle, altsetting)) { + if (!WinUsb_SetCurrentAlternateSetting(winusb_handle, (UCHAR)altsetting)) { usbi_err(ctx, "WinUsb_SetCurrentAlternateSetting failed: %s", windows_error_str(0)); return LIBUSB_ERROR_IO; } diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h index 5da4b9a..cb7cf20 100644 --- a/libusb/os/windows_usb.h +++ b/libusb/os/windows_usb.h @@ -22,7 +22,7 @@ // Windows API default is uppercase - ugh! #if !defined(bool) -#define bool BOOLEAN +#define bool BOOL #endif #if !defined(true) #define true TRUE @@ -56,7 +56,7 @@ void inline upperize(char* str) { size_t i; if (str == NULL) return; for (i=0; i<strlen(str); i++) - str[i] = toupper(str[i]); + str[i] = (char)toupper(str[i]); } #define MAX_CTRL_BUFFER_LENGTH 4096 |