]> sigrok.org Git - libsigrok.git/commitdiff
scpi: Don't process received data of zero length
authorGerhard Sittig <redacted>
Fri, 30 Dec 2016 12:16:04 +0000 (13:16 +0100)
committerUwe Hermann <redacted>
Fri, 20 Jan 2017 17:53:43 +0000 (18:53 +0100)
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

index 8e7e4d74af6702b7b59ba1cd87f163a7468bee3c..adb3e75117a21126a22760e0422331fa9e7530f3 100644 (file)
@@ -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) {