From: Uwe Hermann Date: Tue, 17 Dec 2013 21:17:16 +0000 (+0100) Subject: win32: Add missing ClearCommError() error handling/reporting. X-Git-Tag: libserialport-0.1.0~21 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1a2a1544d73ed288732b409eef95502228e1ed0a;p=libserialport.git win32: Add missing ClearCommError() error handling/reporting. --- diff --git a/serialport.c b/serialport.c index e935464..43dc4d3 100644 --- a/serialport.c +++ b/serialport.c @@ -729,7 +729,8 @@ enum sp_return sp_open(struct sp_port *port, enum sp_mode flags) #endif #ifdef _WIN32 - ClearCommError(port->hdl, &errors, &status); + if (ClearCommError(port->hdl, &errors, &status) == 0) + RETURN_FAIL("ClearCommError() failed"); #endif ret = set_config(port, &data, &config); @@ -1200,7 +1201,7 @@ enum sp_return sp_input_waiting(struct sp_port *port) COMSTAT comstat; if (ClearCommError(port->hdl, &errors, &comstat) == 0) - RETURN_FAIL("ClearComError() failed"); + RETURN_FAIL("ClearCommError() failed"); RETURN_VALUE("%d", comstat.cbInQue); #else int bytes_waiting; @@ -1223,7 +1224,7 @@ enum sp_return sp_output_waiting(struct sp_port *port) COMSTAT comstat; if (ClearCommError(port->hdl, &errors, &comstat) == 0) - RETURN_FAIL("ClearComError() failed"); + RETURN_FAIL("ClearCommError() failed"); RETURN_VALUE("%d", comstat.cbOutQue); #else int bytes_waiting;