Skip to content

Commit

Permalink
libhidpp: hid: windows: Fix CreateEvent() error testing
Browse files Browse the repository at this point in the history
On error CreateEvent() returns NULL and not INVALID_HANDLE_VALUE (-1).
  • Loading branch information
Martin Rubli committed Mar 13, 2023
1 parent f1d52eb commit 0ca96e5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libhidpp/hid/RawDevice_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ RawDevice::RawDevice (const std::string &path):
}

HANDLE event = CreateEvent (NULL, TRUE, TRUE, NULL);
if (event == INVALID_HANDLE_VALUE) {
if (event == NULL) {
err = GetLastError ();
throw std::system_error (err, windows_category (),
"CreateEvent");
Expand Down Expand Up @@ -301,7 +301,7 @@ RawDevice::RawDevice (const std::string &path):


_p->interrupted_event = CreateEvent (NULL, FALSE, FALSE, NULL);
if (_p->interrupted_event == INVALID_HANDLE_VALUE) {
if (_p->interrupted_event == NULL) {
err = GetLastError ();
throw std::system_error (err, windows_category (),
"CreateEvent");
Expand All @@ -328,7 +328,7 @@ RawDevice::RawDevice (const RawDevice &other):
}

HANDLE event = CreateEvent (NULL, TRUE, TRUE, NULL);
if (event == INVALID_HANDLE_VALUE) {
if (event == NULL) {
err = GetLastError ();
throw std::system_error (err, windows_category (),
"CreateEvent");
Expand All @@ -338,7 +338,7 @@ RawDevice::RawDevice (const RawDevice &other):
}

_p->interrupted_event = CreateEvent (NULL, FALSE, FALSE, NULL);
if (_p->interrupted_event == INVALID_HANDLE_VALUE) {
if (_p->interrupted_event == NULL) {
err = GetLastError ();
throw std::system_error (err, windows_category (),
"CreateEvent");
Expand Down

0 comments on commit 0ca96e5

Please sign in to comment.