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~154 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=904401e8fe8175252d68fcf6e0c0edae902c1c17;hp=d3de86f3ca50a55773c6974f0c336e942030b0bd;p=libsigrok.git 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 222201ce..efa839de 100644 --- a/src/scpi/scpi.c +++ b/src/scpi/scpi.c @@ -448,9 +448,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); elapsed_ms = (g_get_monotonic_time() - laststart) / 1000; if (elapsed_ms >= scpi->read_timeout_ms) { sr_err("Timed out waiting for SCPI response.");