]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/center-3xx/api.c
Use g_malloc0() consistently, simplify error handling.
[libsigrok.git] / src / hardware / center-3xx / api.c
index 13831c05a9af4b7b90e4771a31e2587e5bd78d61..c4008d485e9c58fc79d7504f0e809ebdf01e57a2 100644 (file)
@@ -76,8 +76,7 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        struct sr_serial_dev_inst *serial;
        GSList *devices;
 
-       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;
@@ -92,29 +91,21 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(center_devs[idx].vendor);
        sdi->model = g_strdup(center_devs[idx].device);
-
-       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));
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-
        sdi->priv = devc;
        sdi->driver = center_devs[idx].di;
 
        for (i = 0; i <  center_devs[idx].num_channels; i++) {
-               if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG,
-                                          TRUE, channel_names[i])))
-                       goto scan_cleanup;
+               ch = sr_channel_new(i, SR_CHANNEL_ANALOG,
+                                   TRUE, channel_names[i]);
                sdi->channels = g_slist_append(sdi->channels, ch);
        }
 
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
-scan_cleanup:
        serial_close(serial);
 
        return devices;