]> sigrok.org Git - libsigrok.git/blobdiff - src/lcr/es51919.c
sr_dev_inst_free(): Allow NULL as argument.
[libsigrok.git] / src / lcr / es51919.c
index cd901366841b3dfe1a53495dac64786bf2a2cfa0..8d9d9d96476c8e22870baeb06eb4219936484f2b 100644 (file)
@@ -490,21 +490,21 @@ static void parse_measurement(const uint8_t *pkt, float *floatval,
                int unit;
                int exponent;
        } units[] = {
-               { SR_UNIT_UNITLESS,   0 },      /* no unit */
-               { SR_UNIT_OHM,        0 },      /* Ohm     */
-               { SR_UNIT_OHM,        3 },      /* kOhm    */
-               { SR_UNIT_OHM,        6 },      /* MOhm    */
-               { -1,                 0 },      /* ???     */
-               { SR_UNIT_HENRY,     -6 },      /* uH      */
-               { SR_UNIT_HENRY,     -3 },      /* mH      */
-               { SR_UNIT_HENRY,      0 },      /* H       */
-               { SR_UNIT_HENRY,      3 },      /* kH      */
-               { SR_UNIT_FARAD,    -12 },      /* pF      */
-               { SR_UNIT_FARAD,     -9 },      /* nF      */
-               { SR_UNIT_FARAD,     -6 },      /* uF      */
-               { SR_UNIT_FARAD,     -3 },      /* mF      */
-               { SR_UNIT_PERCENTAGE, 0 },      /* %       */
-               { SR_UNIT_DEGREE,     0 },      /* degree  */
+               { SR_UNIT_UNITLESS,   0 }, /* no unit */
+               { SR_UNIT_OHM,        0 }, /* Ohm */
+               { SR_UNIT_OHM,        3 }, /* kOhm */
+               { SR_UNIT_OHM,        6 }, /* MOhm */
+               { -1,                 0 }, /* ??? */
+               { SR_UNIT_HENRY,     -6 }, /* uH */
+               { SR_UNIT_HENRY,     -3 }, /* mH */
+               { SR_UNIT_HENRY,      0 }, /* H */
+               { SR_UNIT_HENRY,      3 }, /* kH */
+               { SR_UNIT_FARAD,    -12 }, /* pF */
+               { SR_UNIT_FARAD,     -9 }, /* nF */
+               { SR_UNIT_FARAD,     -6 }, /* uF */
+               { SR_UNIT_FARAD,     -3 }, /* mF */
+               { SR_UNIT_PERCENTAGE, 0 }, /* % */
+               { SR_UNIT_DEGREE,     0 }, /* degree */
        };
        const uint8_t *buf;
        int digits, exponent;
@@ -535,7 +535,7 @@ static void parse_measurement(const uint8_t *pkt, float *floatval,
                        analog->meaning->mqflags |= SR_MQFLAG_RELATIVE;
        }
 
-       if ((analog->meaning->mq = parse_mq(pkt, is_secondary, pkt[2] & 0x80)) < 0)
+       if ((analog->meaning->mq = parse_mq(pkt, is_secondary, pkt[2] & 0x80)) == 0)
                return;
 
        if ((buf[3] >> 3) >= ARRAY_SIZE(units)) {
@@ -741,14 +741,11 @@ static const char *const channel_names[] = { "P1", "P2" };
 static int setup_channels(struct sr_dev_inst *sdi)
 {
        unsigned int i;
-       int ret;
-
-       ret = SR_ERR_BUG;
 
        for (i = 0; i < ARRAY_SIZE(channel_names); i++)
                sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
 
-       return ret;
+       return SR_OK;
 }
 
 SR_PRIV void es51919_serial_clean(void *priv)
@@ -802,8 +799,7 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options,
 
 scan_cleanup:
        es51919_serial_clean(devc);
-       if (sdi)
-               sr_dev_inst_free(sdi);
+       sr_dev_inst_free(sdi);
        if (serial)
                sr_serial_dev_inst_free(serial);