@@ -1054,48 +1054,43 @@ DWORD WINAPI hid_internal_notify_callback(HCMNOTIFICATION notify, PVOID context,
10541054 read_handle = open_device (event_data -> u .DeviceInterface .SymbolicLink , FALSE);
10551055
10561056 /* Check validity of read_handle. */
1057- if (read_handle = = INVALID_HANDLE_VALUE ) {
1058- /* Unable to open the device. */
1059- return ERROR_SUCCESS ;
1060- }
1061-
1062- device = hid_internal_get_device_info ( event_data -> u . DeviceInterface . SymbolicLink , read_handle ) ;
1063-
1064- /* Append to the end of the device list */
1065- if ( hid_hotplug_context . devs != NULL ) {
1066- struct hid_device_info * last = hid_hotplug_context . devs ;
1067- while ( last -> next != NULL ) {
1068- last = last -> next ;
1057+ if (read_handle ! = INVALID_HANDLE_VALUE ) {
1058+ device = hid_internal_get_device_info ( event_data -> u . DeviceInterface . SymbolicLink , read_handle );
1059+
1060+ /* Append to the end of the device list */
1061+ if ( hid_hotplug_context . devs != NULL ) {
1062+ struct hid_device_info * last = hid_hotplug_context . devs ;
1063+ while ( last -> next != NULL ) {
1064+ last = last -> next ;
1065+ }
1066+ last -> next = device ;
1067+ } else {
1068+ hid_hotplug_context . devs = device ;
10691069 }
1070- last -> next = device ;
1071- } else {
1072- hid_hotplug_context .devs = device ;
1073- }
10741070
1075- CloseHandle (read_handle );
1071+ CloseHandle (read_handle );
1072+ }
10761073 } else if (action == CM_NOTIFY_ACTION_DEVICEINTERFACEREMOVAL ) {
10771074 char * path ;
10781075
10791076 hotplug_event = HID_API_HOTPLUG_EVENT_DEVICE_LEFT ;
10801077
10811078 path = hid_internal_UTF16toUTF8 (event_data -> u .DeviceInterface .SymbolicLink );
10821079
1083- if (path == NULL ) {
1084- return ERROR_SUCCESS ;
1085- }
1086-
1087- /* Get and remove this device from the device list */
1088- for (struct hid_device_info * * current = & hid_hotplug_context .devs ; * current ; current = & (* current )-> next ) {
1089- /* Case-independent path comparison is mandatory */
1090- if (_stricmp ((* current )-> path , path ) == 0 ) {
1091- struct hid_device_info * next = (* current )-> next ;
1092- device = * current ;
1093- * current = next ;
1094- break ;
1080+ if (path != NULL ) {
1081+ /* Get and remove this device from the device list */
1082+ for (struct hid_device_info * * current = & hid_hotplug_context .devs ; * current ; current = & (* current )-> next ) {
1083+ /* Case-independent path comparison is mandatory */
1084+ if (_stricmp ((* current )-> path , path ) == 0 ) {
1085+ struct hid_device_info * next = (* current )-> next ;
1086+ device = * current ;
1087+ * current = next ;
1088+ break ;
1089+ }
10951090 }
1096- }
10971091
1098- free (path );
1092+ free (path );
1093+ }
10991094 }
11001095
11011096 if (device ) {
0 commit comments