]> sigrok.org Git - libsigrok.git/commitdiff
scpi: avoid uninitialized use of a variable
authorGerhard Sittig <redacted>
Thu, 8 Feb 2018 21:08:54 +0000 (22:08 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 20:32:11 +0000 (21:32 +0100)
The 'opc' variable was only conditionally assigned to (depends on
successful SCPI communication). Ensure there always is a known value.

This was reported by clang's scan-build.

src/scpi/scpi.c

index 511e3cd20bc6e56eca6d711e30991ae00046d1a4..5b36daab0dc2bcd1cb943eef3db22864899f655a 100644 (file)
@@ -651,6 +651,7 @@ SR_PRIV int sr_scpi_get_opc(struct sr_scpi_dev_inst *scpi)
        gboolean opc;
 
        for (i = 0; i < SCPI_READ_RETRIES; i++) {
+               opc = FALSE;
                sr_scpi_get_bool(scpi, SCPI_CMD_OPC, &opc);
                if (opc)
                        return SR_OK;