]> sigrok.org Git - libsigrok.git/blobdiff - src/lcr/es51919.c
fx2lafw: Add SR_CONF_CAPTURE_RATIO support.
[libsigrok.git] / src / lcr / es51919.c
index 4cacbe9a134c84d54fb2f4fa46d23e1934a1a6d8..55ea66271a4a502ac82e896e395b6d30ab2a6274 100644 (file)
@@ -41,11 +41,7 @@ static struct dev_buffer *dev_buffer_new(size_t size)
 {
        struct dev_buffer *dbuf;
 
-       if (!(dbuf = g_try_malloc(sizeof(struct dev_buffer) + size))) {
-               sr_err("Dev buffer malloc failed (size=%zu).", size);
-               return NULL;
-       }
-
+       dbuf = g_malloc0(sizeof(struct dev_buffer) + size);
        dbuf->size = size;
        dbuf->len = 0;
        dbuf->offset = 0;
@@ -783,9 +779,7 @@ static int add_channel(struct sr_dev_inst *sdi, const char *name)
 {
        struct sr_channel *ch;
 
-       if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, name)))
-               return SR_ERR;
-
+       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, name);
        sdi->channels = g_slist_append(sdi->channels, ch);
 
        return SR_OK;
@@ -843,22 +837,14 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options,
 
        sr_info("Found device on port %s.", serial->port);
 
-       sdi = sr_dev_inst_new();
+       sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(vendor);
        sdi->model = g_strdup(model);
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
-       if (!(devc->buf = dev_buffer_new(PACKET_SIZE * 8)))
-               goto scan_cleanup;
-
+       devc = g_malloc0(sizeof(struct dev_context));
+       devc->buf = dev_buffer_new(PACKET_SIZE * 8);
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-
        sdi->priv = devc;
 
        if (setup_channels(sdi) != SR_OK)