sr_serial_dev_inst_free(): Allow NULL as argument.
This commit is contained in:
parent
4bf9398802
commit
04891a997c
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue