summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-07-29 19:57:58 +0100
committerPete Batard <pbatard@gmail.com>2010-07-29 20:08:15 +0100
commitf3360dd288be8483c3db8f19351b5cb2a44e94a5 (patch)
treeac4e6dc63b3cb01460340ef88a4b8fe17c49701a
parent48e189898075c26438bcf6782323c5525abc19bd (diff)
downloadlibusb-f3360dd288be8483c3db8f19351b5cb2a44e94a5.tar.gz
fixed -Wshadow compilation errors when using cygwin
NB: this only fixes -Wshadow errors, not -Wshadow warnings
-rw-r--r--libusb/os/poll_windows.c20
-rw-r--r--libusb/os/poll_windows.h3
-rw-r--r--libusb/os/windows_usb.c7
-rw-r--r--libusb/os/windows_usb.h24
4 files changed, 23 insertions, 31 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c
index 10ae696..9ae9895 100644
--- a/libusb/os/poll_windows.c
+++ b/libusb/os/poll_windows.c
@@ -47,12 +47,6 @@
#include <libusbi.h>
-// The following prevents "The function 'InitializeCriticalSection' must be called from within
-// a try/except block" errors when using the MS's WDK OACR/Prefast
-#if defined(_PREFAST_)
-#pragma warning(disable:28125)
-#endif
-
// Uncomment to debug the polling layer
//#define DEBUG_POLL_WINDOWS
#if defined(DEBUG_POLL_WINDOWS)
@@ -75,27 +69,27 @@
// cygwin produces a warning unless these prototypes are defined
extern int _close(int fd);
extern int _snprintf(char *buffer, size_t count, const char *format, ...);
-extern int cygwin_attach_handle_to_fd(char *name, int fd, HANDLE handle, int bin, int access);
+extern int cygwin_attach_handle_to_fd(char *name, int fd, HANDLE handle, int bin, int access_mode);
// _open_osfhandle() is not available on cygwin, but we can emulate
// it for our needs with cygwin_attach_handle_to_fd()
static inline int _open_osfhandle(intptr_t osfhandle, int flags)
{
- int access;
+ int access_mode;
switch (flags) {
case _O_RDONLY:
- access = GENERIC_READ;
+ access_mode = GENERIC_READ;
break;
case _O_WRONLY:
- access = GENERIC_WRITE;
+ access_mode = GENERIC_WRITE;
break;
case _O_RDWR:
- access = GENERIC_READ|GENERIC_WRITE;
+ access_mode = GENERIC_READ|GENERIC_WRITE;
break;
default:
- usbi_err(NULL, "unuspported access mode");
+ usbi_err(NULL, "unsupported access mode");
return -1;
}
- return cygwin_attach_handle_to_fd("/dev/null", -1, (HANDLE)osfhandle, -1, access);
+ return cygwin_attach_handle_to_fd("/dev/null", -1, (HANDLE)osfhandle, -1, access_mode);
}
#endif
diff --git a/libusb/os/poll_windows.h b/libusb/os/poll_windows.h
index fd5d27c..a9e3e90 100644
--- a/libusb/os/poll_windows.h
+++ b/libusb/os/poll_windows.h
@@ -48,7 +48,6 @@ extern enum windows_version windows_version;
#define MAX_FDS 256
-#if !defined(__CYGWIN__)
#define POLLIN 0x0001 /* There is data to read */
#define POLLPRI 0x0002 /* There is urgent data to read */
#define POLLOUT 0x0004 /* Writing now will not block */
@@ -61,7 +60,7 @@ struct pollfd {
short events; /* requested events */
short revents; /* returned events */
};
-#endif
+
typedef unsigned int nfds_t;
// access modes
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 97a1e56..a0e448a 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -1513,7 +1513,10 @@ static int set_device_paths(struct libusb_context *ctx, struct discovered_devs *
break;
default:
// For other devices, the first interface is the same as the device
- priv->usb_interface[0].path = safe_strdup(priv->path); // needs strdup
+ priv->usb_interface[0].path = malloc(safe_strlen(priv->path));
+ if (priv->usb_interface[0].path != NULL) {
+ safe_strcpy(priv->usb_interface[0].path, safe_strlen(priv->path), priv->path);
+ }
// The following is needed if we want to API calls to work for both simple
// and composite devices, as
for(k=0; k<USB_MAXINTERFACES; k++) {
@@ -4237,4 +4240,4 @@ static int composite_copy_transfer_data(struct usbi_transfer *itransfer, uint32_
struct windows_device_priv *priv = __device_priv(transfer->dev_handle->dev);
return priv->usb_interface[transfer_priv->interface_number].apib->copy_transfer_data(itransfer, io_size);
-}
+} \ No newline at end of file
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index 883eb52..f84a4af 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -74,7 +74,6 @@ extern char *_strdup(const char *strSource);
#define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
#define safe_strncmp(str1, str2, count) strncmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
#define safe_strlen(str) ((str==NULL)?0:strlen(str))
-#define safe_strdup _strdup
#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, strlen) WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, strlen, NULL, NULL)
@@ -584,17 +583,14 @@ typedef struct _USB_NODE_CONNECTION_INFORMATION {
// USB_PIPE_INFO PipeList[0];
} USB_NODE_CONNECTION_INFORMATION, *PUSB_NODE_CONNECTION_INFORMATION;
-typedef union _USB_HUB_CAP_FLAGS {
- ULONG ul;
- struct {
- ULONG HubIsHighSpeedCapable:1;
- ULONG HubIsHighSpeed:1;
- ULONG HubIsMultiTtCapable:1;
- ULONG HubIsMultiTt:1;
- ULONG HubIsRoot:1;
- ULONG HubIsArmedWakeOnConnect:1;
- ULONG ReservedMBZ:26;
- };
+typedef struct _USB_HUB_CAP_FLAGS {
+ ULONG HubIsHighSpeedCapable:1;
+ ULONG HubIsHighSpeed:1;
+ ULONG HubIsMultiTtCapable:1;
+ ULONG HubIsMultiTt:1;
+ ULONG HubIsRoot:1;
+ ULONG HubIsArmedWakeOnConnect:1;
+ ULONG ReservedMBZ:26;
} USB_HUB_CAP_FLAGS, *PUSB_HUB_CAP_FLAGS;
typedef struct _USB_HUB_CAPABILITIES {
@@ -742,7 +738,7 @@ typedef struct _HIDP_VALUE_CAPS {
USHORT DesignatorIndex, Reserved3;
USHORT DataIndex, Reserved4;
} NotRange;
- };
+ } u;
} HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;
DLL_DECLARE(WINAPI, BOOL, HidD_GetAttributes, (HANDLE, PHIDD_ATTRIBUTES));
@@ -760,4 +756,4 @@ DLL_DECLARE(WINAPI, BOOL, HidD_GetPhysicalDescriptor, (HANDLE, PVOID, ULONG));
DLL_DECLARE(WINAPI, BOOL, HidD_GetInputReport, (HANDLE, PVOID, ULONG));
DLL_DECLARE(WINAPI, BOOL, HidD_SetOutputReport, (HANDLE, PVOID, ULONG));
DLL_DECLARE(WINAPI, BOOL, HidD_FlushQueue, (HANDLE));
-DLL_DECLARE(WINAPI, BOOL, HidP_GetValueCaps, (HIDP_REPORT_TYPE, PHIDP_VALUE_CAPS, PULONG, PHIDP_PREPARSED_DATA));
+DLL_DECLARE(WINAPI, BOOL, HidP_GetValueCaps, (HIDP_REPORT_TYPE, PHIDP_VALUE_CAPS, PULONG, PHIDP_PREPARSED_DATA)); \ No newline at end of file