aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2017-03-08 19:27:25 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2017-03-10 11:41:34 +0100
commit04891a997c137abb5fa423e7de7f5b9a0fd27a49 (patch)
tree034aad2be8ce66652dca09b196c08c0d61a9fa68
parent4bf93988023b2428129c8145ef9ea7121400f195 (diff)
sr_serial_dev_inst_free(): Allow NULL as argument.
-rw-r--r--src/device.c6
-rw-r--r--src/hardware/gmc-mh-1x-2x/api.c3
-rw-r--r--src/hardware/motech-lps-30x/api.c5
-rw-r--r--src/lcr/es51919.c3
4 files changed, 9 insertions, 8 deletions
diff --git a/src/device.c b/src/device.c
index 38ac003..7122143 100644
--- a/src/device.c
+++ b/src/device.c
@@ -457,12 +457,16 @@ SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(const char *port,
/**
* Free struct sr_serial_dev_inst * allocated by sr_serial_dev_inst().
*
- * @param serial The struct sr_serial_dev_inst * to free. Must not be NULL.
+ * @param serial The struct sr_serial_dev_inst * to free. If NULL, this
+ * function will do nothing.
*
* @private
*/
SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial)
{
+ if (!serial)
+ return;
+
g_free(serial->port);
g_free(serial->serialcomm);
g_free(serial);
diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c
index 2f5d41e..801429c 100644
--- a/src/hardware/gmc-mh-1x-2x/api.c
+++ b/src/hardware/gmc-mh-1x-2x/api.c
@@ -323,8 +323,7 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
exit_err:
sr_info("scan_2x_bd232(): Error!");
- if (serial)
- sr_serial_dev_inst_free(serial);
+ sr_serial_dev_inst_free(serial);
g_free(devc);
sr_dev_inst_free(sdi);
diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c
index 68e4139..4ec35ff 100644
--- a/src/hardware/motech-lps-30x/api.c
+++ b/src/hardware/motech-lps-30x/api.c
@@ -483,10 +483,9 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
exit_err:
sr_info("%s: Error!", __func__);
- if (serial) {
+ if (serial)
serial_close(serial);
- sr_serial_dev_inst_free(serial);
- }
+ sr_serial_dev_inst_free(serial);
g_free(devc);
sr_dev_inst_free(sdi);
diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c
index 8d9d9d9..3a987c6 100644
--- a/src/lcr/es51919.c
+++ b/src/lcr/es51919.c
@@ -800,8 +800,7 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options,
scan_cleanup:
es51919_serial_clean(devc);
sr_dev_inst_free(sdi);
- if (serial)
- sr_serial_dev_inst_free(serial);
+ sr_serial_dev_inst_free(serial);
return NULL;
}