]> sigrok.org Git - libsigrok.git/blobdiff - hardware/openbench-logic-sniffer/ols.c
sr: cleanup callback: Return int.
[libsigrok.git] / hardware / openbench-logic-sniffer / ols.c
index d71c025123cc6446a3b1918a3dd55404a7a03922..264b5658ba84f8d0a3bb5ae13344dd7a22569666 100644 (file)
@@ -521,16 +521,29 @@ 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 ols_device *ols;
+       int ret = SR_OK;
 
        /* Properly close and free all devices. */
        for (l = device_instances; l; l = l->next) {
-               sdi = l->data;
-               ols = sdi->priv;
+               if (!(sdi = l->data)) {
+                       /* Log error, but continue cleaning up the rest. */
+                       sr_err("ols: %s: sdi was NULL, continuing", __func__);
+                       ret = SR_ERR_BUG;
+                       continue;
+               }
+               if (!(ols = sdi->priv)) {
+                       /* Log error, but continue cleaning up the rest. */
+                       sr_err("ols: %s: sdi->priv was NULL, continuing",
+                              __func__);
+                       ret = SR_ERR_BUG;
+                       continue;
+               }
+               /* TODO: Check for serial != NULL. */
                if (ols->serial->fd != -1)
                        serial_close(ols->serial->fd);
                sr_serial_device_instance_free(ols->serial);
@@ -538,6 +551,8 @@ static void hw_cleanup(void)
        }
        g_slist_free(device_instances);
        device_instances = NULL;
+
+       return ret;
 }
 
 static void *hw_get_device_info(int device_index, int device_info_id)
@@ -1010,7 +1025,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data)
        return SR_OK;
 }
 
-static void hw_stop_acquisition(int device_index, gpointer session_device_id)
+static int hw_stop_acquisition(int device_index, gpointer session_device_id)
 {
        struct sr_datafeed_packet packet;
 
@@ -1019,6 +1034,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
 
        packet.type = SR_DF_END;
        sr_session_bus(session_device_id, &packet);
+
+       return SR_OK;
 }
 
 SR_PRIV struct sr_device_plugin ols_plugin_info = {