]> sigrok.org Git - libsigrok.git/commitdiff
motech-lps-301: make better use of serial extract options helper
authorGerhard Sittig <redacted>
Sat, 22 May 2021 11:35:29 +0000 (13:35 +0200)
committerGerhard Sittig <redacted>
Tue, 1 Jun 2021 06:20:59 +0000 (08:20 +0200)
Pre-assign default values before having user specified options scanned.
This avoids the necessity to post-process the result. Move the initial
assignment to where its corresponding update is to improve readability.

src/hardware/motech-lps-30x/api.c

index e4a1fb6b9859d141e0074e8bdb2f430969fdb4ec..31bbfa43827f6c75fecb628bb461f093592fd51e 100644 (file)
@@ -363,13 +363,12 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
 
        sdi = NULL;
        devc = NULL;
-       conn = serialcomm = NULL;
 
        /* Process and check options. */
+       conn = NULL;
+       serialcomm = SERIALCOMM;
        if (sr_serial_extract_options(options, &conn, &serialcomm) != SR_OK)
                return NULL;
-       if (!serialcomm)
-               serialcomm = SERIALCOMM;
 
        /* Init serial port. */
        serial = sr_serial_dev_inst_new(conn, serialcomm);