]> sigrok.org Git - libsigrok.git/commitdiff
sr: don't free driver-specific per-device struct in drivers
authorBert Vermeulen <redacted>
Tue, 14 Feb 2012 11:26:22 +0000 (12:26 +0100)
committerBert Vermeulen <redacted>
Tue, 14 Feb 2012 11:26:22 +0000 (12:26 +0100)
sr_dev_inst_free() takes care of that.

hardware/alsa/alsa.c
hardware/asix-sigma/asix-sigma.c
hardware/chronovu-la8/chronovu-la8.c
hardware/link-mso19/link-mso19.c
hardware/zeroplus-logic-cube/zeroplus.c
session_driver.c

index b04b2216fbba23d4bbcf8db7362fc96154fbe7de..b6dd66c4ca0a92405bb2649a72dbdd397d1c167e 100644 (file)
@@ -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;
index 74b88725045bed9eab147dafa69c781f6c844796..5aed8756d09f97d43be6f9979abcc6e17d055c10 100644 (file)
@@ -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);
index 189d7a8cdc53caaf2f404ef27c18a764f3199c11..507665841a3884b5721b80e6c2e18a2c8097dbf9 100644 (file)
@@ -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. */
index 62640ebf53f42c659990ae8842c25a067b915453..ed310b0b5c1bf48abe7deb80bc40c118cab495c8 100644 (file)
@@ -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)
index 07db8a0e08df39a884d255f4aefd28b4bad0d423..deea5ae4b00dba04433eef39d247bf7b91db7625 100644 (file)
@@ -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;
 
index 6002639ea24d62bf24e3b397ccdba80b0862eead..946676a42c669d1977cb86a0d90581d169743060 100644 (file)
@@ -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;