X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fopenbench-logic-sniffer%2Fprotocol.c;h=d9c2c2bb18bb246a133a2aa6f14703817aff9240;hb=5e23fcab889c62864b92aa3ad6902ce3e9f5be49;hp=c998c29524e1ce8b2c6b8014c42f1de09641121a;hpb=aac29cc192ccf82b64e77b5e6b11b411da32deed;p=libsigrok.git diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index c998c295..d9c2c2bb 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -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; @@ -145,7 +142,6 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) { struct sr_dev_inst *sdi; struct dev_context *devc; - struct sr_channel *ch; uint32_t tmp_int, ui; uint8_t key, type, token; int delay_ms; @@ -218,12 +214,9 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) switch (token) { 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; - sdi->channels = g_slist_append(sdi->channels, ch); - } + for (ui = 0; ui < tmp_int; ui++) + sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE, + ols_channel_names[ui]); break; case 0x01: /* Amount of sample memory available (bytes) */ @@ -257,12 +250,9 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) switch (token) { 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; - sdi->channels = g_slist_append(sdi->channels, ch); - } + for (ui = 0; ui < tmp_c; ui++) + sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE, + ols_channel_names[ui]); break; case 0x01: /* protocol version */