/**
* 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);
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);
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);
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;
}