Skip to content

Commit

Permalink
Added an error message
Browse files Browse the repository at this point in the history
  • Loading branch information
k1-801 committed Nov 21, 2023
1 parent ea5182d commit 87a8bc6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions windows/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ int HID_API_EXPORT hid_init(void)
register_global_error(NULL);
if (!hid_hotplug_context.mutex) {
hid_hotplug_context.mutex = CreateMutexA(NULL, FALSE, NULL);
if(!hid_hotplug_context.mutex) {
register_global_error(L"Failed to create hotplug management mutex");
}
}
#ifndef HIDAPI_USE_DDK
if (!hidapi_initialized) {
Expand All @@ -410,9 +413,11 @@ static void hid_internal_cleanup_hotplugs()
hid_hotplug_context.devs = NULL;
}

if (CM_Unregister_Notification(hid_hotplug_context.notify_handle) != CR_SUCCESS) {
register_global_error(L"hid_hotplug_deregister_callback/CM_Unregister_Notification");
return;
if (hid_hotplug_context.notify_handle) {
if (CM_Unregister_Notification(hid_hotplug_context.notify_handle) != CR_SUCCESS) {
register_global_error(L"hid_hotplug_deregister_callback/CM_Unregister_Notification");
return;
}
}

hid_hotplug_context.notify_handle = NULL;
Expand Down

0 comments on commit 87a8bc6

Please sign in to comment.