Windows: misc improvements

* prefer calloc over malloc
* silence VS2010 intellisense warnings on mem allocation
* other minor fixes and formatting improvements to align with -pbatard
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c
index 5204bcb..2201ffa 100644
--- a/libusb/os/poll_windows.c
+++ b/libusb/os/poll_windows.c
@@ -182,7 +182,7 @@
 
 OVERLAPPED *create_overlapped(void)
 {
-	OVERLAPPED *overlapped = calloc(1, sizeof(OVERLAPPED));
+	OVERLAPPED *overlapped = (OVERLAPPED*) calloc(1, sizeof(OVERLAPPED));
 	if (overlapped == NULL) {
 		return NULL;
 	}
@@ -274,7 +274,7 @@
 
 	CHECK_INIT_POLLING;
 
-	overlapped = calloc(1, sizeof(OVERLAPPED));
+	overlapped = (OVERLAPPED*) calloc(1, sizeof(OVERLAPPED));
 	if (overlapped == NULL) {
 		return -1;
 	}
@@ -572,8 +572,8 @@
 	CHECK_INIT_POLLING;
 
 	triggered = 0;
-	handles_to_wait_on = malloc((nfds+1)*sizeof(HANDLE));	// +1 for fd_update
-	handle_to_index = malloc(nfds*sizeof(int));
+	handles_to_wait_on = (HANDLE*) calloc(nfds+1, sizeof(HANDLE));	// +1 for fd_update
+	handle_to_index = (int*) calloc(nfds, sizeof(int));
 	if ((handles_to_wait_on == NULL) || (handle_to_index == NULL)) {
 		errno = ENOMEM;
 		triggered = -1;
diff --git a/libusb/os/poll_windows.h b/libusb/os/poll_windows.h
index 2aee946..1fe3669 100644
--- a/libusb/os/poll_windows.h
+++ b/libusb/os/poll_windows.h
@@ -38,7 +38,7 @@
 #define STATUS_COMPLETED_SYNCHRONOUSLY	STATUS_REPARSE
 #define HasOverlappedIoCompletedSync(lpOverlapped)	(((DWORD)(lpOverlapped)->Internal) == STATUS_COMPLETED_SYNCHRONOUSLY)
 
-#define DUMMY_HANDLE ((HANDLE)(LONG)-2)
+#define DUMMY_HANDLE ((HANDLE)(LONG_PTR)-2)
 
 enum windows_version {
 	WINDOWS_UNSUPPORTED,
diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c
index c4fa489..bb5c4c8 100644
--- a/libusb/os/threads_windows.c
+++ b/libusb/os/threads_windows.c
@@ -142,7 +142,7 @@
 		}
 	}
 	if(!found) {
-		pos      = malloc(sizeof(struct usbi_cond_perthread));
+		pos      = (struct usbi_cond_perthread*) calloc(1, sizeof(struct usbi_cond_perthread));
 		if(!pos) return ((errno=ENOMEM)); // This errno is not POSIX-allowed.
 		pos->tid = tid;
 		pos->event = CreateEvent(NULL, FALSE, FALSE, NULL); // auto-reset.
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 631cdc7..655edf3 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -122,7 +122,7 @@
 	return false;
 }
 
-#if defined(ENABLE_DEBUG_LOGGING) || (defined(_MSC_VER) && _MSC_VER <= 1200)
+#if defined(ENABLE_DEBUG_LOGGING) || (defined(_MSC_VER) && _MSC_VER < 1400)
 static char* guid_to_string(const GUID* guid)
 {
 	static char guid_string[MAX_GUID_STRING_LENGTH];
@@ -197,7 +197,7 @@
 		size += add_root;
 	}
 
-	if ((ret_path = (char*)calloc(size, 1)) == NULL)
+	if ((ret_path = (char*) calloc(size, 1)) == NULL)
 		return NULL;
 
 	safe_strcpy(&ret_path[add_root], size-add_root, path);
@@ -336,7 +336,7 @@
 		goto err_exit;
 	}
 
-	if ((dev_interface_details = malloc(size)) == NULL) {
+	if ((dev_interface_details = (SP_DEVICE_INTERFACE_DETAIL_DATA_A*) calloc(size, 1)) == NULL) {
 		usbi_err(ctx, "could not allocate interface data for index %u.", _index);
 		goto err_exit;
 	}
@@ -405,7 +405,7 @@
 	htab_filled = 0;
 
 	// allocate memory and zero out.
-	htab_table = (htab_entry*)calloc(htab_size + 1, sizeof(htab_entry));
+	htab_table = (htab_entry*) calloc(htab_size + 1, sizeof(htab_entry));
 	if (htab_table == NULL) {
 		usbi_err(ctx, "could not allocate space for hash table");
 		return 0;
@@ -510,7 +510,7 @@
 	// string (same hash, different string) at the same time is extremely low
 	safe_free(htab_table[idx].str);
 	htab_table[idx].used = hval;
-	htab_table[idx].str = malloc(safe_strlen(str)+1);
+	htab_table[idx].str = (char*) malloc(safe_strlen(str)+1);
 	if (htab_table[idx].str == NULL) {
 		usbi_err(NULL, "could not duplicate string for hash table");
 		usbi_mutex_unlock(&htab_write_mutex);
@@ -580,7 +580,7 @@
 		return LIBUSB_SUCCESS;
 	}
 
-	priv->usb_interface[iface].endpoint = malloc(if_desc->bNumEndpoints);
+	priv->usb_interface[iface].endpoint = (uint8_t*) malloc(if_desc->bNumEndpoints);
 	if (priv->usb_interface[iface].endpoint == NULL) {
 		return LIBUSB_ERROR_NO_MEM;
 	}
@@ -609,7 +609,7 @@
 	size_t len = safe_strlen(driver);
 
 	if (len == 0) return false;
-	tmp_str = calloc(len+1, 1);
+	tmp_str = (char*) calloc(len+1, 1);
 	if (tmp_str == NULL) return false;
 	memcpy(tmp_str, driver, len+1);
 	tok = strtok(tmp_str, sep_str);
@@ -688,8 +688,8 @@
 			if (r == LIBUSB_SUCCESS) {
 				usbi_dbg("auto-released interface %d", transfer_priv->interface_number);
 			} else {
-				usbi_dbg("failed to auto-release interface %d (error=%d)",
-					transfer_priv->interface_number, r);
+				usbi_dbg("failed to auto-release interface %d (%s)",
+					transfer_priv->interface_number, libusb_error_name((enum libusb_error)r));
 			}
 		}
 	}
@@ -891,7 +891,7 @@
 	if (dev->num_configurations == 0)
 		return LIBUSB_ERROR_INVALID_PARAM;
 
-	priv->config_descriptor = malloc(dev->num_configurations * sizeof(PUSB_CONFIGURATION_DESCRIPTOR));
+	priv->config_descriptor = (unsigned char**) calloc(dev->num_configurations, sizeof(PUSB_CONFIGURATION_DESCRIPTOR));
 	if (priv->config_descriptor == NULL)
 		return LIBUSB_ERROR_NO_MEM;
 	for (i=0; i<dev->num_configurations; i++)
@@ -929,7 +929,7 @@
 		}
 
 		size = sizeof(USB_DESCRIPTOR_REQUEST) + cd_buf_short.data.wTotalLength;
-		if ((cd_buf_actual = (PUSB_DESCRIPTOR_REQUEST)malloc(size)) == NULL) {
+		if ((cd_buf_actual = (PUSB_DESCRIPTOR_REQUEST) calloc(1, size)) == NULL) {
 			usbi_err(ctx, "could not allocate configuration descriptor buffer for '%s'.", device_id);
 			LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
 		}
@@ -965,10 +965,9 @@
 			i, cd_data->bConfigurationValue, cd_data->wTotalLength);
 
 		// Cache the descriptor
-		priv->config_descriptor[i] = malloc(cd_data->wTotalLength);
+		priv->config_descriptor[i] = (unsigned char*) malloc(cd_data->wTotalLength);
 		if (priv->config_descriptor[i] == NULL)
 			return LIBUSB_ERROR_NO_MEM;
-
 		memcpy(priv->config_descriptor[i], cd_data, cd_data->wTotalLength);
 	}
 	return LIBUSB_SUCCESS;
@@ -1230,7 +1229,7 @@
 	guid[DEV_PASS] = &GUID_DEVINTERFACE_USB_DEVICE;
 	nb_guids = DEV_PASS+1;
 
-	unref_list = malloc(unref_size*sizeof(libusb_device*));
+	unref_list = (libusb_device**) calloc(unref_size, sizeof(libusb_device*));
 	if (unref_list == NULL) {
 		return LIBUSB_ERROR_NO_MEM;
 	}
@@ -1351,7 +1350,7 @@
 							usbi_err(ctx, "program assertion failed: too many GUIDs");
 							LOOP_BREAK(LIBUSB_ERROR_OVERFLOW);
 						}
-						if_guid = calloc(1, sizeof(GUID));
+						if_guid = (GUID*) calloc(1, sizeof(GUID));
 						pCLSIDFromString(guid_string_w, if_guid);
 						guid[nb_guids++] = if_guid;
 						usbi_dbg("extra GUID: %s", guid_to_string(if_guid));
@@ -1460,9 +1459,11 @@
 					break;
 				default:
 					// For other devices, the first interface is the same as the device
-					priv->usb_interface[0].path = malloc(safe_strlen(priv->path)+1);
+					priv->usb_interface[0].path = (char*) calloc(safe_strlen(priv->path)+1, 1);
 					if (priv->usb_interface[0].path != NULL) {
 						safe_strcpy(priv->usb_interface[0].path, safe_strlen(priv->path)+1, priv->path);
+					} else {
+						usbi_warn(ctx, "could not duplicate interface path '%s'", priv->path);
 					}
 					// The following is needed if we want API calls to work for both simple
 					// and composite devices.
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index d3fc59f..0c71110 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -245,26 +245,26 @@
  * API macros - from libusb-win32 1.x
  */
 #define DLL_DECLARE_PREFIXNAME(api, ret, prefixname, name, args)    \
-	typedef ret (api * __dll_##name##_t)args;                 \
+	typedef ret (api * __dll_##name##_t)args;                       \
 	static __dll_##name##_t prefixname = NULL
 
 #define DLL_LOAD_PREFIXNAME(dll, prefixname, name, ret_on_failure) \
-	do {                                                      \
-		HMODULE h = GetModuleHandleA(#dll);                   \
-	if (!h)                                                   \
-		h = LoadLibraryA(#dll);                               \
-	if (!h) {                                                 \
-		if (ret_on_failure) { return LIBUSB_ERROR_NOT_FOUND; }\
-		else { break; }                                       \
-	}                                                         \
+	do {                                                           \
+		HMODULE h = GetModuleHandleA(#dll);                        \
+	if (!h)                                                        \
+		h = LoadLibraryA(#dll);                                    \
+	if (!h) {                                                      \
+		if (ret_on_failure) { return LIBUSB_ERROR_NOT_FOUND; }     \
+		else { break; }                                            \
+	}                                                              \
 	prefixname = (__dll_##name##_t)GetProcAddress(h, #name);       \
 	if (prefixname) break;                                         \
 	prefixname = (__dll_##name##_t)GetProcAddress(h, #name "A");   \
 	if (prefixname) break;                                         \
 	prefixname = (__dll_##name##_t)GetProcAddress(h, #name "W");   \
 	if (prefixname) break;                                         \
-	if(ret_on_failure)                                        \
-		return LIBUSB_ERROR_NOT_FOUND;                        \
+	if(ret_on_failure)                                             \
+		return LIBUSB_ERROR_NOT_FOUND;                             \
 	} while(0)
 
 #define DLL_DECLARE(api, ret, name, args)   DLL_DECLARE_PREFIXNAME(api, ret, name, name, args)