From: Bert Vermeulen Date: Tue, 14 Feb 2012 11:26:22 +0000 (+0100) Subject: sr: don't free driver-specific per-device struct in drivers X-Git-Tag: libsigrok-0.1.0~121 X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=341ce41545cab2bda88230c8434f36c64eadd8a1;p=libsigrok.git sr: don't free driver-specific per-device struct in drivers sr_dev_inst_free() takes care of that. --- diff --git a/hardware/alsa/alsa.c b/hardware/alsa/alsa.c index b04b2216..b6dd66c4 100644 --- a/hardware/alsa/alsa.c +++ b/hardware/alsa/alsa.c @@ -159,7 +159,6 @@ static int hw_cleanup(void) return SR_ERR_BUG; } - g_free(sdi->priv); sr_dev_inst_free(sdi); return SR_OK; diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 74b88725..5aed8756 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -735,7 +735,6 @@ static int hw_cleanup(void) ret = SR_ERR_BUG; continue; } - g_free(sdi->priv); sr_dev_inst_free(sdi); } g_slist_free(device_instances); diff --git a/hardware/chronovu-la8/chronovu-la8.c b/hardware/chronovu-la8/chronovu-la8.c index 189d7a8c..50766584 100644 --- a/hardware/chronovu-la8/chronovu-la8.c +++ b/hardware/chronovu-la8/chronovu-la8.c @@ -695,17 +695,6 @@ static int hw_cleanup(void) ret = SR_ERR_BUG; continue; } -#if 0 - /* - * Fixes a segfault as it's free()d elsewhere already. - * TODO: Document who is supposed to free this, and when. - */ - if (sdi->priv != NULL) - g_free(sdi->priv); - else - sr_err("la8: %s: sdi->priv was NULL, nothing " - "to do", __func__); -#endif sr_dev_inst_free(sdi); /* Returns void. */ } g_slist_free(device_instances); /* Returns void. */ diff --git a/hardware/link-mso19/link-mso19.c b/hardware/link-mso19/link-mso19.c index 62640ebf..ed310b0b 100644 --- a/hardware/link-mso19/link-mso19.c +++ b/hardware/link-mso19/link-mso19.c @@ -522,8 +522,9 @@ static int hw_cleanup(void) { GSList *l; struct sr_device_instance *sdi; - int ret = SR_OK; + int ret; + ret = SR_OK; /* Properly close all devices. */ for (l = device_instances; l; l = l->next) { if (!(sdi = l->data)) { @@ -534,14 +535,12 @@ static int hw_cleanup(void) } if (sdi->serial->fd != -1) serial_close(sdi->serial->fd); - g_free(sdi->priv); - sdi->priv = NULL; sr_dev_inst_free(sdi); } g_slist_free(device_instances); device_instances = NULL; - return SR_OK; + return ret; } static int hw_opendev(int device_index) diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 07db8a0e..deea5ae4 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -488,16 +488,15 @@ static int hw_closedev(int device_index) static int hw_cleanup(void) { GSList *l; + struct sr_device_instance *sdi; - /* TODO: Error handling. */ - - /* Properly close all devices... */ - for (l = device_instances; l; l = l->next) - close_device((struct sr_device_instance *)l->data); - - /* ...and free all their memory. */ - for (l = device_instances; l; l = l->next) - g_free(l->data); + for (l = device_instances; l; l = l->next) { + sdi = l->data; + /* Properly close all devices... */ + close_device(sdi); + /* ...and free all their memory. */ + sr_dev_inst_free(sdi); + } g_slist_free(device_instances); device_instances = NULL; diff --git a/session_driver.c b/session_driver.c index 6002639e..946676a4 100644 --- a/session_driver.c +++ b/session_driver.c @@ -162,11 +162,8 @@ static int hw_cleanup(void) { GSList *l; - /* TODO: Error handling. */ - for (l = device_instances; l; l = l->next) sr_dev_inst_free(l->data); - g_slist_free(device_instances); device_instances = NULL;