]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/openbench-logic-sniffer/protocol.c
Don't check sr_channel_new() return value (always succeeds).
[libsigrok.git] / src / hardware / openbench-logic-sniffer / protocol.c
index c2b66615e5156781163d9ca02de723d11a018598..b732da59c19e5a271b553a9be7288186e6cb6530 100644 (file)
@@ -124,10 +124,7 @@ SR_PRIV struct dev_context *ols_dev_new(void)
 {
        struct dev_context *devc;
 
-       if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               return NULL;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Device-specific settings */
        devc->max_samples = devc->max_samplerate = devc->protocol_version = 0;
@@ -152,7 +149,7 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
        GString *tmp_str, *devname, *version;
        guchar tmp_c;
 
-       sdi = sr_dev_inst_new();
+       sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INACTIVE;
        sdi->driver = di;
        devc = ols_dev_new();
@@ -219,9 +216,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
                        case 0x00:
                                /* Number of usable channels */
                                for (ui = 0; ui < tmp_int; ui++) {
-                                       if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
-                                                       ols_channel_names[ui])))
-                                               return 0;
+                                       ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+                                                       ols_channel_names[ui]);
                                        sdi->channels = g_slist_append(sdi->channels, ch);
                                }
                                break;
@@ -258,9 +254,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
                        case 0x00:
                                /* Number of usable channels */
                                for (ui = 0; ui < tmp_c; ui++) {
-                                       if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
-                                                       ols_channel_names[ui])))
-                                               return 0;
+                                       ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+                                                       ols_channel_names[ui]);
                                        sdi->channels = g_slist_append(sdi->channels, ch);
                                }
                                break;