]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/appa-55ii/api.c
Use g_malloc0() consistently, simplify error handling.
[libsigrok.git] / src / hardware / appa-55ii / api.c
index 6598757b67d8a6b23ec24f6c5f5f9d34a958255d..771a686c44d5d98837744708db6e8721e756f05a 100644 (file)
@@ -81,8 +81,8 @@ static GSList *scan(GSList *options)
        if (!serialcomm)
                serialcomm = "9600/8n1";
 
-       if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
-               return NULL;
+       serial = sr_serial_dev_inst_new(conn, serialcomm);
+
        if (serial_open(serial, SERIAL_RDONLY) != SR_OK)
                return NULL;
 
@@ -103,24 +103,16 @@ static GSList *scan(GSList *options)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("APPA");
        sdi->model = g_strdup("55II");
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        devc->data_source = DEFAULT_DATA_SOURCE;
-
        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, "T1")))
-               goto scan_cleanup;
+       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T1");
        sdi->channels = g_slist_append(sdi->channels, ch);
-       if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T2")))
-               goto scan_cleanup;
+       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T2");
        sdi->channels = g_slist_append(sdi->channels, ch);
 
        drvc->instances = g_slist_append(drvc->instances, sdi);