]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/conrad-digi-35-cpu/api.c
Use g_malloc0() consistently, simplify error handling.
[libsigrok.git] / src / hardware / conrad-digi-35-cpu / api.c
index 8a9650ecc8def2841af255f802906bc7bf21055d..ed7378ee596e5a9f786102cd90e5e75c0c528a84 100644 (file)
@@ -83,8 +83,7 @@ static GSList *scan(GSList *options)
         * the device is there.
         */
 
-       if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
-               return NULL;
+       serial = sr_serial_dev_inst_new(conn, serialcomm);
 
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                return NULL;
@@ -94,17 +93,15 @@ static GSList *scan(GSList *options)
 
        sr_spew("Conrad DIGI 35 CPU assumed at %s.", conn);
 
-       sdi = sr_dev_inst_new();
+       sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_ACTIVE;
        sdi->vendor = g_strdup("Conrad");
        sdi->model = g_strdup("DIGI 35 CPU");
        sdi->conn = serial;
        sdi->priv = NULL;
        sdi->driver = di;
-       if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1")))
-               return NULL;
+       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1");
        sdi->channels = g_slist_append(sdi->channels, ch);
-
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);