X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fkecheng-kc-330b%2Fapi.c;h=0f8304fc9d1ddc56adbf59bd61951219cd00733d;hb=5fabeeac6af940b52f67ac8c925952accc9b39b3;hp=721ceda12937045c100794fce79147d88d118210;hpb=0af636bed97c174bea46e61e961eaa1b0b162e0f;p=libsigrok.git diff --git a/src/hardware/kecheng-kc-330b/api.c b/src/hardware/kecheng-kc-330b/api.c index 721ceda1..0f8304fc 100644 --- a/src/hardware/kecheng-kc-330b/api.c +++ b/src/hardware/kecheng-kc-330b/api.c @@ -129,21 +129,16 @@ static GSList *scan(GSList *options) for (l = usb_devices; l; l = l->next) { if (scan_kecheng(l->data, &model) != SR_OK) continue; - 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 = model; /* Already g_strndup()'d. */ sdi->driver = di; sdi->inst_type = SR_INST_USB; sdi->conn = l->data; - if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL"))) - return NULL; + ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL"); sdi->channels = g_slist_append(sdi->channels, ch); - - if (!(devc = g_try_malloc(sizeof(struct dev_context)))) { - sr_dbg("Device context malloc failed."); - return NULL; - } + devc = g_malloc0(sizeof(struct dev_context)); sdi->priv = devc; devc->limit_samples = 0; /* The protocol provides no way to read the current