]> sigrok.org Git - libsigrok.git/commitdiff
sr_dev_inst_free(): Allow NULL as argument.
authorUwe Hermann <redacted>
Wed, 8 Mar 2017 18:18:17 +0000 (19:18 +0100)
committerUwe Hermann <redacted>
Fri, 10 Mar 2017 10:38:12 +0000 (11:38 +0100)
src/device.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/hameg-hmo/api.c
src/hardware/lecroy-xstream/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/rohde-schwarz-sme-0x/api.c
src/hardware/yokogawa-dlm/api.c
src/input/input.c
src/lcr/es51919.c

index ace11dd86204b178a63ef903b7006c889ddd8661..38ac003cf01d7433b9c1767ccf3ace01d70329db 100644 (file)
@@ -339,7 +339,7 @@ SR_API int sr_dev_inst_channel_add(struct sr_dev_inst *sdi, int index, int type,
 /**
  * Free device instance struct created by sr_dev_inst().
  *
- * @param sdi Device instance to free. Must not be NULL.
+ * @param sdi Device instance to free. If NULL, the function will do nothing.
  *
  * @private
  */
@@ -349,6 +349,9 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
        struct sr_channel_group *cg;
        GSList *l;
 
+       if (!sdi)
+               return;
+
        for (l = sdi->channels; l; l = l->next) {
                ch = l->data;
                g_free(ch->name);
index 303d435baffdea1e6b21554276a7742b41349d87..2f5d41edb9ee87060f9f196ca1ca475a81412fcb 100644 (file)
@@ -326,8 +326,7 @@ exit_err:
        if (serial)
                sr_serial_dev_inst_free(serial);
        g_free(devc);
-       if (sdi)
-               sr_dev_inst_free(sdi);
+       sr_dev_inst_free(sdi);
 
        return NULL;
 }
index f8fc644cbb2c99b4667451a9998a87a1b85c3059..7bd0b8b4cc8bc12bbcd89778acabd147cbb66a0f 100644 (file)
@@ -100,8 +100,7 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi
 fail:
        if (hw_info)
                sr_scpi_hw_info_free(hw_info);
-       if (sdi)
-               sr_dev_inst_free(sdi);
+       sr_dev_inst_free(sdi);
        g_free(devc);
 
        return NULL;
index 1727ab6d4590e7242942e310690de70963f347f5..9dfb0b643f3f1325fb14e93a578ce7117e842ecd 100644 (file)
@@ -104,8 +104,7 @@ static struct sr_dev_inst *probe_serial_device(struct sr_scpi_dev_inst *scpi)
 
 fail:
        sr_scpi_hw_info_free(hw_info);
-       if (sdi)
-               sr_dev_inst_free(sdi);
+       sr_dev_inst_free(sdi);
        g_free(devc);
 
        return NULL;
index de707f2d1ca946085959d8d53a65dd05fc3570dd..68e4139373073f8ef917081eb4270c2591566523 100644 (file)
@@ -488,8 +488,7 @@ exit_err:
                sr_serial_dev_inst_free(serial);
        }
        g_free(devc);
-       if (sdi)
-               sr_dev_inst_free(sdi);
+       sr_dev_inst_free(sdi);
 
        return NULL;
 }
index 6b84c64a6f72c7008256300b07f64d20a51593d6..9d8548ed5cff1426aac67f50b4dff4f07612d9b5 100644 (file)
@@ -146,10 +146,7 @@ static struct sr_dev_inst *rs_probe_serial_device(struct sr_scpi_dev_inst *scpi)
 fail:
        if (hw_info)
                sr_scpi_hw_info_free(hw_info);
-
-       if (sdi)
-               sr_dev_inst_free(sdi);
-
+       sr_dev_inst_free(sdi);
        g_free(devc);
        return NULL;
 }
index f84482358979ccb3dbf8b5ff92c22fcd780440c7..e14e847d9d6346ea845642299b538950ca44b2ec 100644 (file)
@@ -111,8 +111,7 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
 fail:
        if (hw_info)
                sr_scpi_hw_info_free(hw_info);
-       if (sdi)
-               sr_dev_inst_free(sdi);
+       sr_dev_inst_free(sdi);
        g_free(devc);
 
        return NULL;
index f99902d317c6b4497f520ac5a19738273f413d6b..3db29ffefdee1669795a5ebd854be4ca6eb36d74 100644 (file)
@@ -592,8 +592,7 @@ SR_API void sr_input_free(const struct sr_input *in)
 
        if (in->module->cleanup)
                in->module->cleanup((struct sr_input *)in);
-       if (in->sdi)
-               sr_dev_inst_free(in->sdi);
+       sr_dev_inst_free(in->sdi);
        if (in->buf->len > 64) {
                /* That seems more than just some sub-unitsize leftover... */
                sr_warn("Found %" G_GSIZE_FORMAT
index b80a26c52868c42e559d49f8092e092693d76ad5..8d9d9d96476c8e22870baeb06eb4219936484f2b 100644 (file)
@@ -799,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);