]> sigrok.org Git - libsigrok.git/blobdiff - hardware/demo/demo.c
Return SR_ERR_MALLOC upon allocation errors.
[libsigrok.git] / hardware / demo / demo.c
index ba440a3d0289dd170fa1aa1f1823d035cd366922..b8a4c242b048b5a8dd0c1c4226136be3d0cff9a1 100644 (file)
@@ -63,13 +63,6 @@ enum {
        PATTERN_ALL_HIGH,
 };
 
-/* FIXME: Should not be global. */
-
-/* Private driver context. */
-struct drv_context {
-       GSList *instances;
-};
-
 /* Private, per-device-instance driver context. */
 struct dev_context {
        int pipe_fds[2];
@@ -152,8 +145,8 @@ static int hw_init(void)
        struct drv_context *drvc;
 
        if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
-               sr_err("fx2lafw: driver context malloc failed.");
-               return SR_ERR;
+               sr_err("demo: driver context malloc failed.");
+               return SR_ERR_MALLOC;
        }
        ddi->priv = drvc;
 
@@ -481,14 +474,12 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
                    40, receive_data, devc);
 
        /* Run the demo thread. */
-       g_thread_init(NULL);
-       /* This must to be done between g_thread_init() & g_thread_create(). */
        devc->timer = g_timer_new();
        thread_running = 1;
-       my_thread =
-           g_thread_create((GThreadFunc)thread_func, devc, TRUE, NULL);
+       my_thread = g_thread_try_new("sigrok demo generator",
+                       (GThreadFunc)thread_func, devc, NULL);
        if (!my_thread) {
-               sr_err("demo: %s: g_thread_create failed", __func__);
+               sr_err("demo: %s: g_thread_try_new failed", __func__);
                return SR_ERR; /* TODO */
        }