X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fopenbench-logic-sniffer%2Fprotocol.c;h=b732da59c19e5a271b553a9be7288186e6cb6530;hb=5e1b68c6e7567e0dcf7aff1307c3ffd4852cc15a;hp=c2b66615e5156781163d9ca02de723d11a018598;hpb=0af636bed97c174bea46e61e961eaa1b0b162e0f;p=libsigrok.git diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index c2b66615..b732da59 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; @@ -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;