From 900846816fed39742b221568939f90acebc38f3c Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Fri, 30 Dec 2016 13:16:04 +0100 Subject: [PATCH] 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. --- src/scpi/scpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) {