]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/agilent-dmm/api.c
Use g_malloc0() consistently, simplify error handling.
[libsigrok.git] / src / hardware / agilent-dmm / api.c
index e8767a61ae7c2c2451ec1ae9c7aff999121492c5..374c206a8a6de90eef5f0099ce9e6424b8c5e929 100644 (file)
@@ -112,8 +112,7 @@ static GSList *scan(GSList *options)
        if (!serialcomm)
                serialcomm = SERIALCOMM;
 
-       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;
@@ -144,18 +143,14 @@ static GSList *scan(GSList *options)
                        sdi->vendor = g_strdup("Agilent");
                        sdi->model = g_strdup(tokens[1]);
                        sdi->version = g_strdup(tokens[3]);
-                       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                               sr_err("Device context malloc failed.");
-                               return NULL;
-                       }
+                       devc = g_malloc0(sizeof(struct dev_context));
                        devc->profile = &supported_agdmm[i];
                        devc->cur_mq = -1;
                        sdi->inst_type = SR_INST_SERIAL;
                        sdi->conn = serial;
                        sdi->priv = devc;
                        sdi->driver = di;
-                       if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
-                               return NULL;
+                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
                        sdi->channels = g_slist_append(sdi->channels, ch);
                        drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);