X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhantek-6xxx%2Fapi.c;h=55cf5fdfe91313ec3474317b1fb0894f3a678e61;hb=f4bd8a171816d842303f93bd9a8fb24b851aaa80;hp=cbcd15bf65ea918038eef5cb3c9513ef155252d6;hpb=5eb4ba29d06ed4155ec684117d2bb4a5ed268bb7;p=libsigrok.git diff --git a/src/hardware/hantek-6xxx/api.c b/src/hardware/hantek-6xxx/api.c index cbcd15bf..55cf5fdf 100644 --- a/src/hardware/hantek-6xxx/api.c +++ b/src/hardware/hantek-6xxx/api.c @@ -62,12 +62,12 @@ static const struct hantek_6xxx_profile dev_profiles[] = { { 0x04b4, 0x6022, 0x04b5, 0x6022, "Hantek", "6022BE", "hantek-6022be.fw", - dc_coupling, ARRAY_SIZE(dc_coupling), + dc_coupling, ARRAY_SIZE(dc_coupling), FALSE, }, { 0x8102, 0x8102, 0x1D50, 0x608E, "Sainsmart", "DDS120", "sainsmart-dds120.fw", - acdc_coupling, ARRAY_SIZE(acdc_coupling), + acdc_coupling, ARRAY_SIZE(acdc_coupling), TRUE, }, ALL_ZERO }; @@ -219,7 +219,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)); prof = NULL; - for (j = 0; j < (int)ARRAY_SIZE(dev_profiles); j++) { + for (j = 0; dev_profiles[j].orig_vid; j++) { if (des.idVendor == dev_profiles[j].orig_vid && des.idProduct == dev_profiles[j].orig_pid) { /* Device matches the pre-firmware profile. */ @@ -440,13 +440,13 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd break; case SR_CONF_COUPLING: tmp_str = g_variant_get_string(data, NULL); - for (i = 0; devc->coupling_vals[i]; i++) { + for (i = 0; i < devc->coupling_tab_size; i++) { if (!strcmp(tmp_str, devc->coupling_vals[i])) { devc->coupling[ch_idx] = i; break; } } - if (devc->coupling_vals[i] == 0) + if (i == devc->coupling_tab_size) ret = SR_ERR_ARG; break; default: @@ -465,9 +465,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * GVariantBuilder gvb; unsigned int i; GVariant *gvar; - struct dev_context *devc; - - devc = sdi->priv; + struct dev_context *devc = NULL; if (key == SR_CONF_SCAN_OPTIONS) { *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, @@ -479,8 +477,8 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } - if (!sdi) - return SR_ERR_ARG; + if (sdi) + devc = sdi->priv; if (!cg) { switch (key) { @@ -506,6 +504,8 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t)); break; case SR_CONF_COUPLING: + if (!devc) + return SR_ERR_NA; *data = g_variant_new_strv(devc->coupling_vals, devc->coupling_tab_size); break; case SR_CONF_VDIV: