]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
sr: cleanup callback: Return int.
[libsigrok.git] / hardware / asix-sigma / asix-sigma.c
index 5ed014079887d2f301d5d593443814a90bf416fe..02342aad7926010a02617eea8b1dcb543cfd008a 100644 (file)
@@ -721,20 +721,27 @@ static int hw_closedev(int device_index)
        return SR_OK;
 }
 
-static void hw_cleanup(void)
+static int hw_cleanup(void)
 {
        GSList *l;
        struct sr_device_instance *sdi;
+       int ret = SR_OK;
 
        /* Properly close all devices. */
        for (l = device_instances; l; l = l->next) {
-               sdi = l->data;
-               if (sdi->priv != NULL)
-                       g_free(sdi->priv);
+               if (!(sdi = l->data)) {
+                       /* Log error, but continue cleaning up the rest. */
+                       sr_err("asix: %s: sdi was NULL, continuing", __func__);
+                       ret = SR_ERR_BUG;
+                       continue;
+               }
+               g_free(sdi->priv);
                sr_device_instance_free(sdi);
        }
        g_slist_free(device_instances);
        device_instances = NULL;
+
+       return ret;
 }
 
 static void *hw_get_device_info(int device_index, int device_info_id)