]> sigrok.org Git - libsigrok.git/commitdiff
sr_scpi_hw_info_free(): Allow NULL as argument.
authorUwe Hermann <redacted>
Wed, 8 Mar 2017 18:45:23 +0000 (19:45 +0100)
committerUwe Hermann <redacted>
Fri, 10 Mar 2017 10:41:34 +0000 (11:41 +0100)
src/hardware/hameg-hmo/api.c
src/hardware/rohde-schwarz-sme-0x/api.c
src/hardware/yokogawa-dlm/api.c
src/scpi/scpi.c

index 7bd0b8b4cc8bc12bbcd89778acabd147cbb66a0f..89042da7a4b5adda5c399ed78ca0046f8c04508c 100644 (file)
@@ -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);
 
index 9d8548ed5cff1426aac67f50b4dff4f07612d9b5..7b971b2b4231c3ac1cc3aa13d8392d169bb4ebd0 100644 (file)
@@ -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;
index e14e847d9d6346ea845642299b538950ca44b2ec..bcc24898b4192ca023944b992d51d899fc68fe4b 100644 (file)
@@ -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);
 
index a3a16ebd382e3ef92807709dda601c56206763ab..9ea68b57316db06ad8d324cef67c41016f867227 100644 (file)
@@ -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);
 }