]> sigrok.org Git - libsigrok.git/blobdiff - hardware/saleae-logic/saleae-logic.c
sr: cleanup callback: Return int.
[libsigrok.git] / hardware / saleae-logic / saleae-logic.c
index 14477496e12d546a1fd7ad40118461ed2429e6db..98b9aad134c8f1832ddd0e44d0e6e733bf896181 100644 (file)
@@ -460,16 +460,28 @@ 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;
        struct fx2_device *fx2;
+       int ret = SR_OK;
 
        /* Properly close and free all devices. */
        for (l = device_instances; l; l = l->next) {
-               sdi = l->data;
-               fx2 = sdi->priv;
+               if (!(sdi = l->data)) {
+                       /* Log error, but continue cleaning up the rest. */
+                       sr_err("fx2: %s: sdi was NULL, continuing", __func__);
+                       ret = SR_ERR_BUG;
+                       continue;
+               }
+               if (!(fx2 = sdi->priv)) {
+                       /* Log error, but continue cleaning up the rest. */
+                       sr_err("fx2: %s: sdi->priv was NULL, continuing",
+                              __func__);
+                       ret = SR_ERR_BUG;
+                       continue;
+               }
                close_device(sdi);
                sr_usb_device_instance_free(fx2->usb);
                sr_device_instance_free(sdi);
@@ -481,6 +493,8 @@ static void hw_cleanup(void)
        if (usb_context)
                libusb_exit(usb_context);
        usb_context = NULL;
+
+       return ret;
 }
 
 static void *hw_get_device_info(int device_index, int device_info_id)