summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2017-03-08 19:45:23 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2017-03-10 11:41:34 +0100
commit7b365c47198890da8541a6daf04697c7c7ac88d4 (patch)
treeaba2637c09e9266b44749f216daa0731eb3fcf60
parentce375f2a396c4735a12e9105595d7c9f1a366abb (diff)
sr_scpi_hw_info_free(): Allow NULL as argument.
-rw-r--r--src/hardware/hameg-hmo/api.c3
-rw-r--r--src/hardware/rohde-schwarz-sme-0x/api.c3
-rw-r--r--src/hardware/yokogawa-dlm/api.c3
-rw-r--r--src/scpi/scpi.c20
4 files changed, 13 insertions, 16 deletions
diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c
index 7bd0b8b..89042da 100644
--- a/src/hardware/hameg-hmo/api.c
+++ b/src/hardware/hameg-hmo/api.c
@@ -98,8 +98,7 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi
return sdi;
fail:
- if (hw_info)
- sr_scpi_hw_info_free(hw_info);
+ sr_scpi_hw_info_free(hw_info);
sr_dev_inst_free(sdi);
g_free(devc);
diff --git a/src/hardware/rohde-schwarz-sme-0x/api.c b/src/hardware/rohde-schwarz-sme-0x/api.c
index 9d8548e..7b971b2 100644
--- a/src/hardware/rohde-schwarz-sme-0x/api.c
+++ b/src/hardware/rohde-schwarz-sme-0x/api.c
@@ -144,8 +144,7 @@ static struct sr_dev_inst *rs_probe_serial_device(struct sr_scpi_dev_inst *scpi)
return sdi;
fail:
- if (hw_info)
- sr_scpi_hw_info_free(hw_info);
+ sr_scpi_hw_info_free(hw_info);
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 e14e847..bcc2489 100644
--- a/src/hardware/yokogawa-dlm/api.c
+++ b/src/hardware/yokogawa-dlm/api.c
@@ -109,8 +109,7 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
return sdi;
fail:
- if (hw_info)
- sr_scpi_hw_info_free(hw_info);
+ sr_scpi_hw_info_free(hw_info);
sr_dev_inst_free(sdi);
g_free(devc);
diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c
index a3a16eb..9ea68b5 100644
--- a/src/scpi/scpi.c
+++ b/src/scpi/scpi.c
@@ -934,17 +934,17 @@ SR_PRIV int sr_scpi_get_hw_id(struct sr_scpi_dev_inst *scpi,
/**
* Free a sr_scpi_hw_info struct.
*
- * @param hw_info Pointer to the struct to free.
- *
- * This function is safe to call with a NULL pointer.
+ * @param hw_info Pointer to the struct to free. If NULL, this
+ * function does nothing.
*/
SR_PRIV void sr_scpi_hw_info_free(struct sr_scpi_hw_info *hw_info)
{
- if (hw_info) {
- g_free(hw_info->manufacturer);
- g_free(hw_info->model);
- g_free(hw_info->serial_number);
- g_free(hw_info->firmware_version);
- g_free(hw_info);
- }
+ if (!hw_info)
+ return;
+
+ g_free(hw_info->manufacturer);
+ g_free(hw_info->model);
+ g_free(hw_info->serial_number);
+ g_free(hw_info->firmware_version);
+ g_free(hw_info);
}