From: Uwe Hermann Date: Fri, 21 Jul 2017 06:10:19 +0000 (+0200) Subject: drivers: Use ARRAY_AND_SIZE where possible. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=53012da658ae94b245240c8a3e115723eede4c7d;p=libsigrok.git drivers: Use ARRAY_AND_SIZE where possible. --- diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index 76ee21c4..1e462a17 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -268,10 +268,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; case SR_CONF_DATA_SOURCE: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; default: return SR_ERR_NA; diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index aecfc262..892b4ad5 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -171,7 +171,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_DATA_SOURCE: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; default: return SR_ERR_NA; diff --git a/src/hardware/arachnid-labs-re-load-pro/api.c b/src/hardware/arachnid-labs-re-load-pro/api.c index 91b086aa..0aa2b7bf 100644 --- a/src/hardware/arachnid-labs-re-load-pro/api.c +++ b/src/hardware/arachnid-labs-re-load-pro/api.c @@ -155,7 +155,7 @@ static int config_list(uint32_t key, GVariant **data, } else { switch (key) { case SR_CONF_DEVICE_OPTIONS: - *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg)); break; case SR_CONF_CURRENT_LIMIT: *data = std_gvar_min_max_step(0.0, 6.0, 0.001); diff --git a/src/hardware/asix-sigma/api.c b/src/hardware/asix-sigma/api.c index 5b169d56..c9b787e7 100644 --- a/src/hardware/asix-sigma/api.c +++ b/src/hardware/asix-sigma/api.c @@ -243,7 +243,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * break; #if ASIX_SIGMA_WITH_TRIGGER case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); break; #endif default: diff --git a/src/hardware/atten-pps3xxx/api.c b/src/hardware/atten-pps3xxx/api.c index d4ab7f89..1a783b7a 100644 --- a/src/hardware/atten-pps3xxx/api.c +++ b/src/hardware/atten-pps3xxx/api.c @@ -265,8 +265,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd switch (key) { case SR_CONF_CHANNEL_CONFIG: sval = g_variant_get_string(data, NULL); - if ((ival = find_str(sval, channel_modes, - ARRAY_SIZE(channel_modes))) == -1) { + if ((ival = find_str(sval, ARRAY_AND_SIZE(channel_modes))) == -1) { ret = SR_ERR_ARG; break; } @@ -347,7 +346,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * *data = g_variant_new_strv(channel_modes, 1); } else { /* The other models support all modes. */ - *data = g_variant_new_strv(channel_modes, ARRAY_SIZE(channel_modes)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(channel_modes)); } break; default: @@ -360,7 +359,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * switch (key) { case SR_CONF_DEVICE_OPTIONS: - *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg)); break; case SR_CONF_VOLTAGE_TARGET: *data = std_gvar_min_max_step_array(devc->model->channels[channel].voltage); diff --git a/src/hardware/baylibre-acme/api.c b/src/hardware/baylibre-acme/api.c index 4438c642..e96bff27 100644 --- a/src/hardware/baylibre-acme/api.c +++ b/src/hardware/baylibre-acme/api.c @@ -227,7 +227,7 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; default: return SR_ERR_NA; diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index b570c112..1ed11a62 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -245,10 +245,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(soft_trigger_matches)); break; default: return SR_ERR_NA; diff --git a/src/hardware/cem-dt-885x/api.c b/src/hardware/cem-dt-885x/api.c index 1c456ce0..d7a75b60 100644 --- a/src/hardware/cem-dt-885x/api.c +++ b/src/hardware/cem-dt-885x/api.c @@ -289,16 +289,16 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SPL_WEIGHT_FREQ: - *data = g_variant_new_strv(weight_freq, ARRAY_SIZE(weight_freq)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_freq)); break; case SR_CONF_SPL_WEIGHT_TIME: - *data = g_variant_new_strv(weight_time, ARRAY_SIZE(weight_time)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_time)); break; case SR_CONF_SPL_MEASUREMENT_RANGE: *data = std_gvar_tuple_array(&meas_ranges, ARRAY_SIZE(meas_ranges)); break; case SR_CONF_DATA_SOURCE: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; default: return SR_ERR_NA; diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index 47d34927..022c61f8 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -357,7 +357,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: cv_fill_samplerates_if_needed(sdi); - *data = std_gvar_samplerates(devc->samplerates, ARRAY_SIZE(devc->samplerates)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(devc->samplerates)); break; case SR_CONF_LIMIT_SAMPLES: if (!devc->prof) diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index a2d39736..fcf61cb3 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -362,7 +362,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; default: return SR_ERR_NA; @@ -372,12 +372,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * switch (key) { case SR_CONF_DEVICE_OPTIONS: if (ch->type == SR_CHANNEL_LOGIC) - *data = std_gvar_array_u32(devopts_cg_logic, ARRAY_SIZE(devopts_cg_logic)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_logic)); else if (ch->type == SR_CHANNEL_ANALOG) { if (strcmp(cg->name, "Analog") == 0) - *data = std_gvar_array_u32(devopts_cg_analog_group, ARRAY_SIZE(devopts_cg_analog_group)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog_group)); else - *data = std_gvar_array_u32(devopts_cg_analog_channel, ARRAY_SIZE(devopts_cg_analog_channel)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog_channel)); } else return SR_ERR_BUG; @@ -388,11 +388,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_ERR_NA; if (ch->type == SR_CHANNEL_LOGIC) - *data = g_variant_new_strv(logic_pattern_str, - ARRAY_SIZE(logic_pattern_str)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(logic_pattern_str)); else if (ch->type == SR_CHANNEL_ANALOG) - *data = g_variant_new_strv(analog_pattern_str, - ARRAY_SIZE(analog_pattern_str)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(analog_pattern_str)); else return SR_ERR_BUG; break; diff --git a/src/hardware/dreamsourcelab-dslogic/api.c b/src/hardware/dreamsourcelab-dslogic/api.c index 41f8a737..fe49d5f3 100644 --- a/src/hardware/dreamsourcelab-dslogic/api.c +++ b/src/hardware/dreamsourcelab-dslogic/api.c @@ -535,8 +535,7 @@ static int config_set(uint32_t key, GVariant *data, devc->continuous_mode = g_variant_get_boolean(data); break; case SR_CONF_CLOCK_EDGE: - i = lookup_index(data, signal_edge_names, - ARRAY_SIZE(signal_edge_names)); + i = lookup_index(data, ARRAY_AND_SIZE(signal_edge_names)); if (i < 0) return SR_ERR_ARG; devc->clock_edge = i; @@ -580,8 +579,7 @@ static int config_list(uint32_t key, GVariant **data, *data = std_gvar_samplerates(devc->samplerates, devc->num_samplerates); break; case SR_CONF_CLOCK_EDGE: - *data = g_variant_new_strv(signal_edge_names, - ARRAY_SIZE(signal_edge_names)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(signal_edge_names)); break; default: return SR_ERR_NA; diff --git a/src/hardware/ftdi-la/api.c b/src/hardware/ftdi-la/api.c index d435c64a..1341730b 100644 --- a/src/hardware/ftdi-la/api.c +++ b/src/hardware/ftdi-la/api.c @@ -388,7 +388,7 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; default: return SR_ERR_NA; diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index ec0ee480..5b6dd9d1 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -543,7 +543,7 @@ static int config_list(uint32_t key, GVariant **data, *data = std_gvar_samplerates(devc->samplerates, devc->num_samplerates); break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(soft_trigger_matches)); break; default: return SR_ERR_NA; diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index bb066dc2..c4b75fe9 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -460,14 +460,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * switch (key) { case SR_CONF_SCAN_OPTIONS: - *data = std_gvar_array_u32(scanopts, ARRAY_SIZE(scanopts)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(scanopts)); break; case SR_CONF_DEVICE_OPTIONS: if (cg_type == CG_NONE) { if (model) *data = std_gvar_array_u32((const uint32_t *)model->devopts, model->num_devopts); else - *data = std_gvar_array_u32(drvopts, ARRAY_SIZE(drvopts)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(drvopts)); } else if (cg_type == CG_ANALOG) { *data = std_gvar_array_u32((const uint32_t *)model->devopts_cg_analog, model->num_devopts_cg_analog); } else { diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index 2fa50efb..47563d3e 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -462,7 +462,7 @@ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi, if (sr_scpi_get_string(scpi, command, &tmp_str) != SR_OK) return SR_ERR; - if (array_float_get(tmp_str, vdivs, ARRAY_SIZE(vdivs), &j) != SR_OK) { + if (array_float_get(tmp_str, ARRAY_AND_SIZE(vdivs), &j) != SR_OK) { g_free(tmp_str); sr_err("Could not determine array index for vertical div scale."); return SR_ERR; @@ -627,7 +627,7 @@ SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi) &tmp_str) != SR_OK) return SR_ERR; - if (array_float_get(tmp_str, timebases, ARRAY_SIZE(timebases), &i) != SR_OK) { + if (array_float_get(tmp_str, ARRAY_AND_SIZE(timebases), &i) != SR_OK) { g_free(tmp_str); sr_err("Could not determine array index for time base."); return SR_ERR; diff --git a/src/hardware/hantek-6xxx/api.c b/src/hardware/hantek-6xxx/api.c index 5e19ccc4..6b3cbcc2 100644 --- a/src/hardware/hantek-6xxx/api.c +++ b/src/hardware/hantek-6xxx/api.c @@ -63,17 +63,17 @@ static const struct hantek_6xxx_profile dev_profiles[] = { { 0x04b4, 0x6022, 0x1d50, 0x608e, 0x0001, "Hantek", "6022BE", "fx2lafw-hantek-6022be.fw", - dc_coupling, ARRAY_SIZE(dc_coupling), FALSE, + ARRAY_AND_SIZE(dc_coupling), FALSE, }, { 0x8102, 0x8102, 0x1d50, 0x608e, 0x0002, "Sainsmart", "DDS120", "fx2lafw-sainsmart-dds120.fw", - acdc_coupling, ARRAY_SIZE(acdc_coupling), TRUE, + ARRAY_AND_SIZE(acdc_coupling), TRUE, }, { 0x04b4, 0x602a, 0x1d50, 0x608e, 0x0003, "Hantek", "6022BL", "fx2lafw-hantek-6022bl.fw", - dc_coupling, ARRAY_SIZE(dc_coupling), FALSE, + ARRAY_AND_SIZE(dc_coupling), FALSE, }, ALL_ZERO }; @@ -468,7 +468,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates)); break; default: return SR_ERR_NA; @@ -476,7 +476,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * } else { switch (key) { case SR_CONF_DEVICE_OPTIONS: - *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg)); break; case SR_CONF_COUPLING: *data = g_variant_new_strv(devc->coupling_vals, devc->coupling_tab_size); diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index 65f11bfc..f00d8b6c 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -611,12 +611,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * *data = std_gvar_tuple_array(&timebases, ARRAY_SIZE(timebases)); break; case SR_CONF_TRIGGER_SOURCE: - *data = g_variant_new_strv(trigger_sources, - ARRAY_SIZE(trigger_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_sources)); break; case SR_CONF_TRIGGER_SLOPE: - *data = g_variant_new_strv(trigger_slopes, - ARRAY_SIZE(trigger_slopes)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_slopes)); break; default: return SR_ERR_NA; @@ -624,10 +622,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * } else { switch (key) { case SR_CONF_DEVICE_OPTIONS: - *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg)); break; case SR_CONF_COUPLING: - *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(coupling)); break; case SR_CONF_VDIV: *data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs)); diff --git a/src/hardware/hung-chang-dso-2100/api.c b/src/hardware/hung-chang-dso-2100/api.c index 8b268e21..f7515d74 100644 --- a/src/hardware/hung-chang-dso-2100/api.c +++ b/src/hardware/hung-chang-dso-2100/api.c @@ -358,8 +358,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s *data = g_variant_new_uint64(samplerates[devc->rate]); break; case SR_CONF_TRIGGER_SOURCE: - i = reverse_map(devc->cctl[0] & 0xC0, trigger_sources_map, - ARRAY_SIZE(trigger_sources_map)); + i = reverse_map(devc->cctl[0] & 0xC0, ARRAY_AND_SIZE(trigger_sources_map)); if (i == -1) return SR_ERR; else @@ -378,8 +377,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s if (ch == -1) { return SR_ERR_CHANNEL_GROUP; } else { - i = reverse_map(devc->cctl[ch] & 0x33, vdivs_map, - ARRAY_SIZE(vdivs_map)); + i = reverse_map(devc->cctl[ch] & 0x33, ARRAY_AND_SIZE(vdivs_map)); if (i == -1) return SR_ERR; else @@ -391,8 +389,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s if (ch == -1) { return SR_ERR_CHANNEL_GROUP; } else { - i = reverse_map(devc->cctl[ch] & 0x0C, coupling_map, - ARRAY_SIZE(coupling_map)); + i = reverse_map(devc->cctl[ch] & 0x0C, ARRAY_AND_SIZE(coupling_map)); if (i == -1) return SR_ERR; else @@ -428,7 +425,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd break; case SR_CONF_SAMPLERATE: i = find_in_array(data, G_VARIANT_TYPE_UINT64, - samplerates, ARRAY_SIZE(samplerates)); + ARRAY_AND_SIZE(samplerates)); if (i == -1) return SR_ERR_ARG; else @@ -436,7 +433,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd break; case SR_CONF_TRIGGER_SOURCE: i = find_in_array(data, G_VARIANT_TYPE_STRING, - trigger_sources, ARRAY_SIZE(trigger_sources)); + ARRAY_AND_SIZE(trigger_sources)); if (i == -1) return SR_ERR_ARG; else @@ -445,7 +442,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd break; case SR_CONF_TRIGGER_SLOPE: i = find_in_array(data, G_VARIANT_TYPE_STRING, - trigger_slopes, ARRAY_SIZE(trigger_slopes)); + ARRAY_AND_SIZE(trigger_slopes)); if (i == -1) return SR_ERR_ARG; else @@ -453,7 +450,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd break; case SR_CONF_BUFFERSIZE: i = find_in_array(data, G_VARIANT_TYPE_UINT64, - buffersizes, ARRAY_SIZE(buffersizes)); + ARRAY_AND_SIZE(buffersizes)); if (i == -1) return SR_ERR_ARG; else @@ -481,7 +478,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd return SR_ERR_CHANNEL_GROUP; } else { i = find_in_array(data, G_VARIANT_TYPE_STRING, - coupling, ARRAY_SIZE(coupling)); + ARRAY_AND_SIZE(coupling)); if (i == -1) return SR_ERR_ARG; else @@ -592,25 +589,25 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: if (!cg) return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); - *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg)); break; case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates)); break; case SR_CONF_TRIGGER_SOURCE: - *data = g_variant_new_strv(trigger_sources, ARRAY_SIZE(trigger_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_sources)); break; case SR_CONF_TRIGGER_SLOPE: - *data = g_variant_new_strv(trigger_slopes, ARRAY_SIZE(trigger_slopes)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_slopes)); break; case SR_CONF_BUFFERSIZE: - *data = std_gvar_array_u64(buffersizes, ARRAY_SIZE(buffersizes)); + *data = std_gvar_array_u64(ARRAY_AND_SIZE(buffersizes)); break; case SR_CONF_VDIV: *data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs)); break; case SR_CONF_COUPLING: - *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(coupling)); break; } diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c index 7e3c21c3..1b2a26f4 100644 --- a/src/hardware/ikalogic-scanalogic2/api.c +++ b/src/hardware/ikalogic-scanalogic2/api.c @@ -306,10 +306,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates(sl2_samplerates, ARRAY_SIZE(sl2_samplerates)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(sl2_samplerates)); break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); break; case SR_CONF_LIMIT_SAMPLES: grange[0] = g_variant_new_uint64(0); diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index ffec385c..5aded17b 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -261,7 +261,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates)); break; default: return SR_ERR_NA; diff --git a/src/hardware/kecheng-kc-330b/api.c b/src/hardware/kecheng-kc-330b/api.c index 8d0703cc..dc651325 100644 --- a/src/hardware/kecheng-kc-330b/api.c +++ b/src/hardware/kecheng-kc-330b/api.c @@ -332,13 +332,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * ARRAY_SIZE(kecheng_kc_330b_sample_intervals)); break; case SR_CONF_SPL_WEIGHT_FREQ: - *data = g_variant_new_strv(weight_freq, ARRAY_SIZE(weight_freq)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_freq)); break; case SR_CONF_SPL_WEIGHT_TIME: - *data = g_variant_new_strv(weight_time, ARRAY_SIZE(weight_time)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_time)); break; case SR_CONF_DATA_SOURCE: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; default: return SR_ERR_NA; diff --git a/src/hardware/lecroy-logicstudio/api.c b/src/hardware/lecroy-logicstudio/api.c index 2682f7bd..f61d69ae 100644 --- a/src/hardware/lecroy-logicstudio/api.c +++ b/src/hardware/lecroy-logicstudio/api.c @@ -410,10 +410,10 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates)); break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); break; default: return SR_ERR_NA; diff --git a/src/hardware/lecroy-logicstudio/protocol.c b/src/hardware/lecroy-logicstudio/protocol.c index 78376a45..d48ed4a6 100644 --- a/src/hardware/lecroy-logicstudio/protocol.c +++ b/src/hardware/lecroy-logicstudio/protocol.c @@ -310,7 +310,7 @@ static int fetch_samples_async(const struct sr_dev_inst *sdi) prep_regw(&cmd[i++], REG_FETCH_SAMPLES, devc->magic_fetch_samples + 0x01); prep_regw(&cmd[i++], REG_FETCH_SAMPLES, devc->magic_fetch_samples | 0x02); - return write_registers_async(sdi, 0x12, 5444, cmd, ARRAY_SIZE(cmd), + return write_registers_async(sdi, 0x12, 5444, ARRAY_AND_SIZE(cmd), handle_fetch_samples_done); } @@ -522,7 +522,7 @@ static int upload_trigger(const struct sr_dev_inst *sdi, prep_regw(®s[k++], REG_TRIGGER_CFG, value); } - if (write_registers_sync(sdi, 0x12, 5444, regs, ARRAY_SIZE(regs))) { + if (write_registers_sync(sdi, 0x12, 5444, ARRAY_AND_SIZE(regs))) { sr_err("Failed to upload trigger config."); return SR_ERR; } @@ -1162,7 +1162,7 @@ SR_PRIV int lls_start_acquisition(const struct sr_dev_inst *sdi) devc->magic_arm_trigger = 0x0c; prep_regw(&cmd[i++], REG_ARM_TRIGGER, devc->magic_arm_trigger | 0x01); - return write_registers_sync(sdi, 0x12, 5444, cmd, ARRAY_SIZE(cmd)); + return write_registers_sync(sdi, 0x12, 5444, ARRAY_AND_SIZE(cmd)); } SR_PRIV int lls_stop_acquisition(const struct sr_dev_inst *sdi) @@ -1182,5 +1182,5 @@ SR_PRIV int lls_stop_acquisition(const struct sr_dev_inst *sdi) assert(i == ARRAY_SIZE(cmd)); - return write_registers_sync(sdi, 0x12, 5444, cmd, ARRAY_SIZE(cmd)); + return write_registers_sync(sdi, 0x12, 5444, ARRAY_AND_SIZE(cmd)); } diff --git a/src/hardware/lecroy-xstream/api.c b/src/hardware/lecroy-xstream/api.c index f5139702..fb056931 100644 --- a/src/hardware/lecroy-xstream/api.c +++ b/src/hardware/lecroy-xstream/api.c @@ -381,7 +381,7 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_DEVICE_OPTIONS: if (!cg) return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); - *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog)); break; case SR_CONF_COUPLING: *data = g_variant_new_strv(*model->coupling_options, diff --git a/src/hardware/lecroy-xstream/protocol.c b/src/hardware/lecroy-xstream/protocol.c index 18c02061..ce9b24d5 100644 --- a/src/hardware/lecroy-xstream/protocol.c +++ b/src/hardware/lecroy-xstream/protocol.c @@ -292,7 +292,7 @@ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi, if (sr_scpi_get_string(scpi, command, &tmp_str) != SR_OK) return SR_ERR; - if (array_float_get(tmp_str, vdivs, ARRAY_SIZE(vdivs), &j) != SR_OK) { + if (array_float_get(tmp_str, ARRAY_AND_SIZE(vdivs), &j) != SR_OK) { g_free(tmp_str); sr_err("Could not determine array index for vertical div scale."); return SR_ERR; @@ -366,7 +366,7 @@ SR_PRIV int lecroy_xstream_state_get(struct sr_dev_inst *sdi) if (sr_scpi_get_string(sdi->conn, "TIME_DIV?", &tmp_str) != SR_OK) return SR_ERR; - if (array_float_get(tmp_str, timebases, ARRAY_SIZE(timebases), &i) != SR_OK) { + if (array_float_get(tmp_str, ARRAY_AND_SIZE(timebases), &i) != SR_OK) { g_free(tmp_str); sr_err("Could not determine array index for timbase scale."); return SR_ERR; diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index ae1a7f68..4e043c3a 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -292,7 +292,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; case SR_CONF_TRIGGER_TYPE: *data = g_variant_new_string(TRIGGER_TYPE); diff --git a/src/hardware/maynuo-m97/api.c b/src/hardware/maynuo-m97/api.c index c2083f7b..e7fffb86 100644 --- a/src/hardware/maynuo-m97/api.c +++ b/src/hardware/maynuo-m97/api.c @@ -368,7 +368,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * } else { switch (key) { case SR_CONF_DEVICE_OPTIONS: - *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg)); break; case SR_CONF_VOLTAGE_TARGET: *data = std_gvar_min_max_step(0.0, devc->model->max_voltage, 0.001); diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c index be5d7256..fb48ef09 100644 --- a/src/hardware/motech-lps-30x/api.c +++ b/src/hardware/motech-lps-30x/api.c @@ -667,7 +667,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * *data = g_variant_new_strv(channel_modes, 1); } else { /* The other models support all modes. */ - *data = g_variant_new_strv(channel_modes, ARRAY_SIZE(channel_modes)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(channel_modes)); } return SR_OK; default: @@ -682,9 +682,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * switch (key) { case SR_CONF_DEVICE_OPTIONS: if ((ch_idx == 0) || (ch_idx == 1)) /* CH1, CH2 */ - *data = std_gvar_array_u32(devopts_cg_ch12, ARRAY_SIZE(devopts_cg_ch12)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_ch12)); else /* Must be CH3 */ - *data = std_gvar_array_u32(devopts_cg_ch3, ARRAY_SIZE(devopts_cg_ch3)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_ch3)); break; case SR_CONF_VOLTAGE_TARGET: *data = std_gvar_min_max_step_array(devc->model->channels[ch_idx].voltage); diff --git a/src/hardware/openbench-logic-sniffer/api.c b/src/hardware/openbench-logic-sniffer/api.c index dccd025d..9b95e18c 100644 --- a/src/hardware/openbench-logic-sniffer/api.c +++ b/src/hardware/openbench-logic-sniffer/api.c @@ -331,13 +331,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); break; case SR_CONF_PATTERN_MODE: - *data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(patterns)); break; case SR_CONF_LIMIT_SAMPLES: if (!sdi) diff --git a/src/hardware/pce-322a/api.c b/src/hardware/pce-322a/api.c index dea7740c..1ab19a8d 100644 --- a/src/hardware/pce-322a/api.c +++ b/src/hardware/pce-322a/api.c @@ -244,16 +244,16 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SPL_WEIGHT_FREQ: - *data = g_variant_new_strv(weight_freq, ARRAY_SIZE(weight_freq)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_freq)); break; case SR_CONF_SPL_WEIGHT_TIME: - *data = g_variant_new_strv(weight_time, ARRAY_SIZE(weight_time)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_time)); break; case SR_CONF_SPL_MEASUREMENT_RANGE: *data = std_gvar_tuple_array(&meas_ranges, ARRAY_SIZE(meas_ranges)); break; case SR_CONF_DATA_SOURCE: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; default: return SR_ERR_NA; diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index 5006380b..29ba0fed 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -341,13 +341,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); break; case SR_CONF_PATTERN_MODE: - *data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(patterns)); break; case SR_CONF_LIMIT_SAMPLES: if (!sdi) diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 8bf40c5e..72f41b4c 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -856,7 +856,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * } else { for (i = 0; i < devc->model->analog_channels; i++) { if (cg == devc->analog_groups[i]) { - *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog)); return SR_OK; } } @@ -866,12 +866,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_COUPLING: if (!cg) return SR_ERR_CHANNEL_GROUP; - *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(coupling)); break; case SR_CONF_PROBE_FACTOR: if (!cg) return SR_ERR_CHANNEL_GROUP; - *data = std_gvar_array_u64(probe_factor, ARRAY_SIZE(probe_factor)); + *data = std_gvar_array_u64(ARRAY_AND_SIZE(probe_factor)); break; case SR_CONF_VDIV: if (!devc) @@ -897,7 +897,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * devc->model->has_digital ? ARRAY_SIZE(trigger_sources) : 4); break; case SR_CONF_TRIGGER_SLOPE: - *data = g_variant_new_strv(trigger_slopes, ARRAY_SIZE(trigger_slopes)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_slopes)); break; case SR_CONF_DATA_SOURCE: if (!devc) @@ -911,7 +911,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources) - 1); break; default: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; } break; diff --git a/src/hardware/saleae-logic-pro/api.c b/src/hardware/saleae-logic-pro/api.c index bd96e3de..1131a43d 100644 --- a/src/hardware/saleae-logic-pro/api.c +++ b/src/hardware/saleae-logic-pro/api.c @@ -355,7 +355,7 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates)); break; default: return SR_ERR_NA; diff --git a/src/hardware/saleae-logic-pro/protocol.c b/src/hardware/saleae-logic-pro/protocol.c index 1d7eba40..94cab7fb 100644 --- a/src/hardware/saleae-logic-pro/protocol.c +++ b/src/hardware/saleae-logic-pro/protocol.c @@ -217,7 +217,7 @@ static int write_adc(const struct sr_dev_inst *sdi, {REG_ADC_VAL_MSB, value >> 8}, }; - return write_regs(sdi, regs, G_N_ELEMENTS(regs)); + return write_regs(sdi, ARRAY_AND_SIZE(regs)); } static int read_eeprom(const struct sr_dev_inst *sdi, @@ -564,7 +564,7 @@ static int set_led(const struct sr_dev_inst *sdi, uint8_t r, uint8_t g, uint8_t authenticate(sdi); - return write_regs(sdi, regs, G_N_ELEMENTS(regs)); + return write_regs(sdi, ARRAY_AND_SIZE(regs)); } #endif @@ -788,8 +788,8 @@ SR_PRIV int saleae_logic_pro_prepare(const struct sr_dev_inst *sdi) authenticate(sdi); write_reg(sdi, 0x15, 0x03); - write_regs(sdi, regs_unknown, G_N_ELEMENTS(regs_unknown)); - write_regs(sdi, regs_config, G_N_ELEMENTS(regs_config)); + write_regs(sdi, ARRAY_AND_SIZE(regs_unknown)); + write_regs(sdi, ARRAY_AND_SIZE(regs_config)); transact(sdi, start_req, sizeof(start_req), start_rsp, sizeof(start_rsp)); diff --git a/src/hardware/saleae-logic16/api.c b/src/hardware/saleae-logic16/api.c index 9bbe169f..66dd9ba5 100644 --- a/src/hardware/saleae-logic16/api.c +++ b/src/hardware/saleae-logic16/api.c @@ -511,7 +511,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: - *data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates)); break; case SR_CONF_VOLTAGE_THRESHOLD: g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY); @@ -524,7 +524,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * *data = g_variant_builder_end(&gvb); break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(soft_trigger_matches)); break; default: return SR_ERR_NA; diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 5a847eb2..f97b0710 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -524,8 +524,8 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_SCAN_OPTIONS: case SR_CONF_DEVICE_OPTIONS: return std_opts_config_list(key, data, sdi, cg, - scanopts, ARRAY_SIZE(scanopts), - drvopts, ARRAY_SIZE(drvopts), + ARRAY_AND_SIZE(scanopts), + ARRAY_AND_SIZE(drvopts), (devc) ? devc->device->devopts : NULL, (devc) ? devc->device->num_devopts : 0); break; diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index 4e4fc3a5..127324f2 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -448,22 +448,19 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd ? CLOCK_EXT_CLK : CLOCK_INTERNAL; break; case SR_CONF_CLOCK_EDGE: - idx = lookup_index(data, signal_edge_names, - ARRAY_SIZE(signal_edge_names)); + idx = lookup_index(data, ARRAY_AND_SIZE(signal_edge_names)); if (idx < 0) return SR_ERR_ARG; devc->cfg_clock_edge = idx; break; case SR_CONF_TRIGGER_SOURCE: - idx = lookup_index(data, trigger_source_names, - ARRAY_SIZE(trigger_source_names)); + idx = lookup_index(data, ARRAY_AND_SIZE(trigger_source_names)); if (idx < 0) return SR_ERR_ARG; devc->cfg_trigger_source = idx; break; case SR_CONF_TRIGGER_SLOPE: - idx = lookup_index(data, signal_edge_names, - ARRAY_SIZE(signal_edge_names)); + idx = lookup_index(data, ARRAY_AND_SIZE(signal_edge_names)); if (idx < 0) return SR_ERR_ARG; devc->cfg_trigger_slope = idx; @@ -607,8 +604,7 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_SCAN_OPTIONS: case SR_CONF_DEVICE_OPTIONS: return std_opts_config_list(key, data, sdi, cg, - scanopts, ARRAY_SIZE(scanopts), - drvopts, ARRAY_SIZE(drvopts), + ARRAY_AND_SIZE(scanopts), ARRAY_AND_SIZE(drvopts), (devc) ? devc->model->devopts : NULL, (devc) ? devc->model->num_devopts : 0); } @@ -621,16 +617,14 @@ static int config_list(uint32_t key, GVariant **data, *data = std_gvar_samplerates(devc->model->samplerates, devc->model->num_samplerates); break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); break; case SR_CONF_TRIGGER_SOURCE: - *data = g_variant_new_strv(trigger_source_names, - ARRAY_SIZE(trigger_source_names)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_source_names)); break; case SR_CONF_TRIGGER_SLOPE: case SR_CONF_CLOCK_EDGE: - *data = g_variant_new_strv(signal_edge_names, - ARRAY_SIZE(signal_edge_names)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(signal_edge_names)); break; default: /* Must not happen for a key listed in devopts. */ diff --git a/src/hardware/sysclk-lwla/lwla.c b/src/hardware/sysclk-lwla/lwla.c index 6e6413fb..dd36f87f 100644 --- a/src/hardware/sysclk-lwla/lwla.c +++ b/src/hardware/sysclk-lwla/lwla.c @@ -169,7 +169,7 @@ SR_PRIV int lwla_read_reg(const struct sr_usb_dev_inst *usb, command[0] = LWLA_WORD(CMD_READ_REG); command[1] = LWLA_WORD(reg); - ret = lwla_send_command(usb, command, ARRAY_SIZE(command)); + ret = lwla_send_command(usb, ARRAY_AND_SIZE(command)); if (ret != SR_OK) return ret; @@ -197,7 +197,7 @@ SR_PRIV int lwla_write_reg(const struct sr_usb_dev_inst *usb, command[2] = LWLA_WORD_0(value); command[3] = LWLA_WORD_1(value); - return lwla_send_command(usb, command, ARRAY_SIZE(command)); + return lwla_send_command(usb, ARRAY_AND_SIZE(command)); } SR_PRIV int lwla_write_regs(const struct sr_usb_dev_inst *usb, diff --git a/src/hardware/sysclk-lwla/lwla1016.c b/src/hardware/sysclk-lwla/lwla1016.c index 4b412fb5..1c0391f5 100644 --- a/src/hardware/sysclk-lwla/lwla1016.c +++ b/src/hardware/sysclk-lwla/lwla1016.c @@ -197,7 +197,7 @@ static int test_read_memory(const struct sr_dev_inst *sdi, command[3] = LWLA_WORD_0(count); command[4] = LWLA_WORD_1(count); - ret = lwla_send_command(usb, command, ARRAY_SIZE(command)); + ret = lwla_send_command(usb, ARRAY_AND_SIZE(command)); if (ret != SR_OK) return ret; @@ -269,7 +269,7 @@ static int device_init_check(const struct sr_dev_inst *sdi) return SR_ERR; } - ret = lwla_write_regs(sdi->conn, mem_reset, ARRAY_SIZE(mem_reset)); + ret = lwla_write_regs(sdi->conn, ARRAY_AND_SIZE(mem_reset)); if (ret != SR_OK) return ret; @@ -318,7 +318,7 @@ static int setup_acquisition(const struct sr_dev_inst *sdi) if (ret != SR_OK) return ret; - ret = lwla_write_regs(usb, capture_init, ARRAY_SIZE(capture_init)); + ret = lwla_write_regs(usb, ARRAY_AND_SIZE(capture_init)); if (ret != SR_OK) return ret; diff --git a/src/hardware/sysclk-lwla/lwla1034.c b/src/hardware/sysclk-lwla/lwla1034.c index 63ca46f5..0f5215a5 100644 --- a/src/hardware/sysclk-lwla/lwla1034.c +++ b/src/hardware/sysclk-lwla/lwla1034.c @@ -274,7 +274,7 @@ static int detect_short_transfer_quirk(const struct sr_dev_inst *sdi) command[1] = LWLA_WORD(0); command[2] = LWLA_WORD(lreg_count); - ret = lwla_send_command(usb, command, ARRAY_SIZE(command)); + ret = lwla_send_command(usb, ARRAY_AND_SIZE(command)); if (ret != SR_OK) return ret; @@ -373,7 +373,7 @@ static int setup_acquisition(const struct sr_dev_inst *sdi) usb = sdi->conn; acq = devc->acquisition; - ret = lwla_write_regs(usb, capture_init, ARRAY_SIZE(capture_init)); + ret = lwla_write_regs(usb, ARRAY_AND_SIZE(capture_init)); if (ret != SR_OK) return ret; diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index aa8aca8b..c6d2ae60 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -213,7 +213,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_DATA_SOURCE: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; default: return SR_ERR_NA; diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index 5bba8d9b..28480f52 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -489,9 +489,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * switch (key) { case SR_CONF_DEVICE_OPTIONS: if (cg_type == CG_ANALOG) - *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog)); else if (cg_type == CG_DIGITAL) - *data = std_gvar_array_u32(devopts_cg_digital, ARRAY_SIZE(devopts_cg_digital)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_digital)); else *data = std_gvar_array_u32(NULL, 0); break; diff --git a/src/hardware/yokogawa-dlm/protocol.c b/src/hardware/yokogawa-dlm/protocol.c index 0dff00d6..1937a71c 100644 --- a/src/hardware/yokogawa-dlm/protocol.c +++ b/src/hardware/yokogawa-dlm/protocol.c @@ -454,7 +454,7 @@ static int analog_channel_state_get(const struct sr_dev_inst *sdi, if (dlm_analog_chan_vdiv_get(scpi, i + 1, &response) != SR_OK) return SR_ERR; - if (array_float_get(response, dlm_vdivs, ARRAY_SIZE(dlm_vdivs), + if (array_float_get(response, ARRAY_AND_SIZE(dlm_vdivs), &j) != SR_OK) { g_free(response); return SR_ERR; @@ -692,8 +692,7 @@ SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi) if (dlm_timebase_get(sdi->conn, &response) != SR_OK) return SR_ERR; - if (array_float_get(response, dlm_timebases, - ARRAY_SIZE(dlm_timebases), &i) != SR_OK) { + if (array_float_get(response, ARRAY_AND_SIZE(dlm_timebases), &i) != SR_OK) { g_free(response); return SR_ERR; } diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index af8e6203..5f0cd9f0 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -399,9 +399,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_SAMPLERATE: devc = sdi->priv; if (devc->prof->max_sampling_freq == 100) - *data = std_gvar_samplerates(samplerates_100, ARRAY_SIZE(samplerates_100)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates_100)); else if (devc->prof->max_sampling_freq == 200) - *data = std_gvar_samplerates(samplerates_200, ARRAY_SIZE(samplerates_200)); + *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates_200)); else { sr_err("Internal error: Unknown max. samplerate: %d.", devc->prof->max_sampling_freq); @@ -409,7 +409,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * } break; case SR_CONF_TRIGGER_MATCH: - *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches)); + *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); break; case SR_CONF_VOLTAGE_THRESHOLD: *data = std_gvar_min_max_step_thresholds(-6.0, 6.0, 0.1); diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c index 02e6dd02..9030a4ba 100644 --- a/src/lcr/es51919.c +++ b/src/lcr/es51919.c @@ -857,10 +857,10 @@ SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data, return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_OUTPUT_FREQUENCY: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_DOUBLE, - frequencies, ARRAY_SIZE(frequencies), sizeof(double)); + ARRAY_AND_SIZE(frequencies), sizeof(double)); break; case SR_CONF_EQUIV_CIRCUIT_MODEL: - *data = g_variant_new_strv(models, ARRAY_SIZE(models)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(models)); break; default: return SR_ERR_NA;