From: Gerhard Sittig Date: Fri, 30 Dec 2016 12:16:04 +0000 (+0100) Subject: scpi: Don't process received data of zero length X-Git-Tag: libsigrok-0.5.0~140 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=900846816fed39742b221568939f90acebc38f3c scpi: Don't process received data of zero length When nothing was received in a read attempt, we need not adjust the buffered data's read position nor the glib string object's size. Skip any processing for empty input, just keep checking for timeouts. --- diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c index 8e7e4d74..adb3e751 100644 --- a/src/scpi/scpi.c +++ b/src/scpi/scpi.c @@ -453,9 +453,9 @@ SR_PRIV int sr_scpi_get_data(struct sr_scpi_dev_inst *scpi, return SR_ERR; } else if (len > 0) { laststart = g_get_monotonic_time(); + offset += len; + g_string_set_size(response, offset); } - offset += len; - g_string_set_size(response, offset); /* Quit reading after a period of time without receive data. */ elapsed_ms = (g_get_monotonic_time() - laststart) / 1000; if (elapsed_ms >= scpi->read_timeout_ms) {