return SR_OK;
}
-static void hw_cleanup(void)
+static int hw_cleanup(void)
{
struct sr_device_instance *sdi;
- if (!(sdi = sr_get_device_instance(device_instances, 0)))
- return;
+ if (!(sdi = sr_get_device_instance(device_instances, 0))) {
+ sr_err("alsa: %s: sdi was NULL", __func__);
+ return SR_ERR_BUG;
+ }
g_free(sdi->priv);
sr_device_instance_free(sdi);
+
+ return SR_OK;
}
static void *hw_get_device_info(int device_index, int device_info_id)
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)
return SR_OK;
}
-static void hw_cleanup(void)
+static int hw_cleanup(void)
{
GSList *l;
struct sr_device_instance *sdi;
+ int ret = SR_OK;
sr_spew("la8: entering %s", __func__);
/* Properly close all devices. */
for (l = device_instances; l; l = l->next) {
- if ((sdi = l->data) == NULL) {
+ if (!(sdi = l->data)) {
+ /* Log error, but continue cleaning up the rest. */
sr_err("la8: %s: sdi was NULL, continuing", __func__);
+ ret = SR_ERR_BUG;
continue;
}
#if 0
}
g_slist_free(device_instances); /* Returns void. */
device_instances = NULL;
+
+ return ret;
}
static void *hw_get_device_info(int device_index, int device_info_id)
return SR_OK;
}
-static void hw_cleanup(void)
+static int hw_cleanup(void)
{
/* Nothing needed so far. */
+ return SR_OK;
}
static void *hw_get_device_info(int device_index, int device_info_id)
return devcnt;
}
-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 = l->data)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("mso19: %s: sdi was NULL, continuing", __func__);
+ ret = SR_ERR_BUG;
+ continue;
+ }
if (sdi->serial->fd != -1)
serial_close(sdi->serial->fd);
- if (sdi->priv != NULL)
- {
- g_free(sdi->priv);
- sdi->priv = NULL;
- }
+ g_free(sdi->priv);
+ sdi->priv = NULL;
sr_device_instance_free(sdi);
}
g_slist_free(device_instances);
device_instances = NULL;
+
+ return SR_OK;
}
static int hw_opendev(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);
}
g_slist_free(device_instances);
device_instances = NULL;
+
+ return ret;
}
static void *hw_get_device_info(int device_index, int device_info_id)
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);
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)
return SR_OK;
}
-static void hw_cleanup(void)
+static int hw_cleanup(void)
{
GSList *l;
+ /* TODO: Error handling. */
+
/* Properly close all devices... */
for (l = device_instances; l; l = l->next)
close_device((struct sr_device_instance *)l->data);
if (usb_context)
libusb_exit(usb_context);
usb_context = NULL;
+
+ return SR_OK;
}
static void *hw_get_device_info(int device_index, int device_info_id)
}
/* driver callbacks */
-static void hw_cleanup(void);
+static int hw_cleanup(void);
/**
* TODO.
*/
static int hw_init(const char *deviceinfo)
{
-
sessionfile = g_strdup(deviceinfo);
return 0;
* TODO.
*
*/
-static void hw_cleanup(void)
+static int hw_cleanup(void)
{
GSList *l;
+ /* TODO: Error handling. */
+
for (l = device_instances; l; l = l->next)
sr_device_instance_free(l->data);
sr_session_source_remove(-1);
g_free(sessionfile);
+
+ return SR_OK;
}
static int hw_opendev(int device_index)
char *longname;
int api_version;
int (*init) (const char *deviceinfo);
- void (*cleanup) (void);
+ int (*cleanup) (void);
/* Device-specific */
int (*opendev) (int device_index);