From: Uwe Hermann Date: Wed, 8 Mar 2017 18:45:23 +0000 (+0100) Subject: sr_scpi_hw_info_free(): Allow NULL as argument. X-Git-Tag: libsigrok-0.5.0~91 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7b365c47198890da8541a6daf04697c7c7ac88d4;p=libsigrok.git sr_scpi_hw_info_free(): Allow NULL as argument. --- diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index 7bd0b8b4..89042da7 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 9d8548ed..7b971b2b 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 e14e847d..bcc24898 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 a3a16ebd..9ea68b57 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); }