aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2017-03-08 19:18:17 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2017-03-10 11:38:12 +0100
commit4bf93988023b2428129c8145ef9ea7121400f195 (patch)
treea12611b68a71302de00e17882a1020addc4201de
parent8662130615d7a59883c303914f94377032101cb9 (diff)
sr_dev_inst_free(): Allow NULL as argument.
-rw-r--r--src/device.c5
-rw-r--r--src/hardware/gmc-mh-1x-2x/api.c3
-rw-r--r--src/hardware/hameg-hmo/api.c3
-rw-r--r--src/hardware/lecroy-xstream/api.c3
-rw-r--r--src/hardware/motech-lps-30x/api.c3
-rw-r--r--src/hardware/rohde-schwarz-sme-0x/api.c5
-rw-r--r--src/hardware/yokogawa-dlm/api.c3
-rw-r--r--src/input/input.c3
-rw-r--r--src/lcr/es51919.c3
9 files changed, 12 insertions, 19 deletions
diff --git a/src/device.c b/src/device.c
index ace11dd..38ac003 100644
--- a/src/device.c
+++ b/src/device.c
@@ -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);
diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c
index 303d435..2f5d41e 100644
--- a/src/hardware/gmc-mh-1x-2x/api.c
+++ b/src/hardware/gmc-mh-1x-2x/api.c
@@ -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;
}
diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c
index f8fc644..7bd0b8b 100644
--- a/src/hardware/hameg-hmo/api.c
+++ b/src/hardware/hameg-hmo/api.c
@@ -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;
diff --git a/src/hardware/lecroy-xstream/api.c b/src/hardware/lecroy-xstream/api.c
index 1727ab6..9dfb0b6 100644
--- a/src/hardware/lecroy-xstream/api.c
+++ b/src/hardware/lecroy-xstream/api.c
@@ -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;
diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c
index de707f2..68e4139 100644
--- a/src/hardware/motech-lps-30x/api.c
+++ b/src/hardware/motech-lps-30x/api.c
@@ -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;
}
diff --git a/src/hardware/rohde-schwarz-sme-0x/api.c b/src/hardware/rohde-schwarz-sme-0x/api.c
index 6b84c64..9d8548e 100644
--- a/src/hardware/rohde-schwarz-sme-0x/api.c
+++ b/src/hardware/rohde-schwarz-sme-0x/api.c
@@ -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;
}
diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c
index f844823..e14e847 100644
--- a/src/hardware/yokogawa-dlm/api.c
+++ b/src/hardware/yokogawa-dlm/api.c
@@ -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;
diff --git a/src/input/input.c b/src/input/input.c
index f99902d..3db29ff 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -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
diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c
index b80a26c..8d9d9d9 100644
--- a/src/lcr/es51919.c
+++ b/src/lcr/es51919.c
@@ -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);