X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fgmc-mh-1x-2x%2Fapi.c;h=efb9e009c71b4d25f0b3a2fa66a12ca38f443e8e;hb=da005885c8ebbf98772f75126764f758b2640d11;hp=69b26794156f4988fd279bc8adc81173ebefa4b0;hpb=1beccaed464a4d92a070988a0331fe399f9f7a7a;p=libsigrok.git diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index 69b26794..efb9e009 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -108,7 +108,7 @@ static enum model scan_model_sm(struct sr_serial_dev_inst *serial) gint64 timeout_us; model = METRAHIT_NONE; - timeout_us = g_get_monotonic_time() + 1 * 1000 * 1000; + timeout_us = g_get_monotonic_time() + (1 * 1000 * 1000); /* * Try to find message consisting of device code and several @@ -296,18 +296,18 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options) goto exit_err; /* Wait for reply from device(s) for up to 2s. */ - timeout_us = g_get_monotonic_time() + 2*1000*1000; + timeout_us = g_get_monotonic_time() + (2 * 1000 * 1000); while (timeout_us > g_get_monotonic_time()) { /* Receive reply (14 bytes) */ devc->buflen = 0; - for (cnt = 0; cnt < 14; cnt++) { + for (cnt = 0; cnt < GMC_REPLY_SIZE; cnt++) { byte = read_byte(serial, timeout_us); if (byte != -1) devc->buf[devc->buflen++] = (byte & MASK_6BITS); } - if (devc->buflen != 14) + if (devc->buflen != GMC_REPLY_SIZE) continue; devc->addr = devc->buf[0]; @@ -345,8 +345,7 @@ exit_err: if (serial) sr_serial_dev_inst_free(serial); - if (devc) - g_free(devc); + g_free(devc); if (sdi) sr_dev_inst_free(sdi); @@ -389,8 +388,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s (void)cg; - ret = SR_OK; - if (!sdi || !(devc = sdi->priv)) return SR_ERR_ARG;