]> sigrok.org Git - libserialport.git/commitdiff
windows: Always check return value of GetOverlappedResult().
authorMartin Ling <redacted>
Thu, 7 May 2015 08:19:47 +0000 (09:19 +0100)
committerUwe Hermann <redacted>
Wed, 27 May 2015 09:09:25 +0000 (11:09 +0200)
serialport.c

index 8d71865bad14ce5dc55d36f44d83570fb08c8d8a..39500f8f93fa699e17c5b13bf6292551ae388198 100644 (file)
@@ -763,7 +763,8 @@ SP_API enum sp_return sp_blocking_write(struct sp_port *port, const void *buf,
                RETURN_INT(count);
        } else if (GetLastError() == ERROR_IO_PENDING) {
                DEBUG("Waiting for write to complete");
-               GetOverlappedResult(port->hdl, &port->write_ovl, &bytes_written, TRUE);
+               if (GetOverlappedResult(port->hdl, &port->write_ovl, &bytes_written, TRUE) == 0)
+                       RETURN_FAIL("GetOverlappedResult() failed");
                DEBUG_FMT("Write completed, %d/%d bytes written", bytes_written, count);
                RETURN_INT(bytes_written);
        } else {
@@ -973,7 +974,8 @@ SP_API enum sp_return sp_blocking_read(struct sp_port *port, void *buf,
                bytes_read = count;
        } else if (GetLastError() == ERROR_IO_PENDING) {
                DEBUG("Waiting for read to complete");
-               GetOverlappedResult(port->hdl, &port->read_ovl, &bytes_read, TRUE);
+               if (GetOverlappedResult(port->hdl, &port->read_ovl, &bytes_read, TRUE) == 0)
+                       RETURN_FAIL("GetOverlappedResult() failed");
                DEBUG_FMT("Read completed, %d/%d bytes read", bytes_read, count);
        } else {
                RETURN_FAIL("ReadFile() failed");