浏览代码

hidapi, windows: Fix -Wjump-misses-init warning (#14990)

Clang: jump from this goto statement to its label is incompatible with C++ [-Wjump-misses-init]
RaceTheMaSe 3 周之前
父节点
当前提交
ba3274e3a1
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      src/hidapi/windows/hid.c

+ 7 - 3
src/hidapi/windows/hid.c

@@ -1027,6 +1027,12 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
 			continue;
 		}
 
+#ifdef HIDAPI_IGNORE_DEVICE
+		hid_bus_type bus_type = HID_API_BUS_UNKNOWN;
+		PHIDP_PREPARSED_DATA pp_data = NULL;
+		HIDP_CAPS caps = { 0 };
+#endif
+
 		/* Get the Vendor ID and Product ID for this device. */
 		attrib.Size = sizeof(HIDD_ATTRIBUTES);
 		if (!HidD_GetAttributes(device_handle, &attrib)) {
@@ -1035,9 +1041,7 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
 
 #ifdef HIDAPI_IGNORE_DEVICE
 		/* See if there are any devices we should skip in enumeration */
-		hid_bus_type bus_type = get_bus_type(device_interface);
-		PHIDP_PREPARSED_DATA pp_data = NULL;
-		HIDP_CAPS caps = { 0 };
+		bus_type = get_bus_type(device_interface);
 		if (HidD_GetPreparsedData(device_handle, &pp_data)) {
 			HidP_GetCaps(pp_data, &caps);
 			HidD_FreePreparsedData(pp_data);