]> sigrok.org Git - libsigrok.git/commitdiff
drivers: Use ARRAY_AND_SIZE where possible.
authorUwe Hermann <redacted>
Fri, 21 Jul 2017 06:10:19 +0000 (08:10 +0200)
committerUwe Hermann <redacted>
Fri, 21 Jul 2017 15:06:40 +0000 (17:06 +0200)
45 files changed:
src/hardware/agilent-dmm/api.c
src/hardware/appa-55ii/api.c
src/hardware/arachnid-labs-re-load-pro/api.c
src/hardware/asix-sigma/api.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/beaglelogic/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/chronovu-la/api.c
src/hardware/demo/api.c
src/hardware/dreamsourcelab-dslogic/api.c
src/hardware/ftdi-la/api.c
src/hardware/fx2lafw/api.c
src/hardware/hameg-hmo/api.c
src/hardware/hameg-hmo/protocol.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/ikalogic-scanaplus/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/lecroy-logicstudio/api.c
src/hardware/lecroy-logicstudio/protocol.c
src/hardware/lecroy-xstream/api.c
src/hardware/lecroy-xstream/protocol.c
src/hardware/link-mso19/api.c
src/hardware/maynuo-m97/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/pce-322a/api.c
src/hardware/pipistrello-ols/api.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic-pro/api.c
src/hardware/saleae-logic-pro/protocol.c
src/hardware/saleae-logic16/api.c
src/hardware/scpi-pps/api.c
src/hardware/sysclk-lwla/api.c
src/hardware/sysclk-lwla/lwla.c
src/hardware/sysclk-lwla/lwla1016.c
src/hardware/sysclk-lwla/lwla1034.c
src/hardware/uni-t-ut32x/api.c
src/hardware/yokogawa-dlm/api.c
src/hardware/yokogawa-dlm/protocol.c
src/hardware/zeroplus-logic-cube/api.c
src/lcr/es51919.c

index 76ee21c4d0a53db18b046d89feac82212d5fc872..1e462a170f6bab8019d3965950c9f7df4171d953 100644 (file)
@@ -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;
index aecfc262960a7f1f387b189128c523a16a2b030c..892b4ad5de686478d0c8ed6d4d586a5cd5278377 100644 (file)
@@ -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;
index 91b086aafc6b7e7dcf9a704db54c09f4467abf22..0aa2b7bff9794c535da67279fd62f45634b40a2c 100644 (file)
@@ -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);
index 5b169d5646f5a768337092998396403b123c455d..c9b787e73ac8ac2976468cd81e3982a630931d08 100644 (file)
@@ -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:
index d4ab7f89389f140eef67eb2f99a087227c93c7ff..1a783b7a456cd75455918ce5c034d9066d2f986c 100644 (file)
@@ -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);
index 4438c64274516df43a4650bf5ed1976caa8d3eda..e96bff27b5eacb69d8f108da1b2adf52eb5a9e4d 100644 (file)
@@ -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;
index b570c112b0c5fe51a98614e23d366e9c3998ea43..1ed11a628f8faa11549cbe8d1a3620912269ac09 100644 (file)
@@ -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;
index 1c456ce0585b5edff014994c1ddc54ec9070a7fc..d7a75b6003e372cbb3a5e8806733f15293565a8d 100644 (file)
@@ -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;
index 47d349275b8e59f4b70086cbf108758b96afef35..022c61f894e06f9520d825a716a87a6b7611a9e0 100644 (file)
@@ -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)
index a2d397365d02c981ad357210af4d69ff15ded0cc..fcf61cb3f54d1c2b9727a50cd4e7579d835fb2b6 100644 (file)
@@ -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;
index 41f8a737965170eff2859be24626851e39ba8007..fe49d5f325f68ac0dec57946165fd539f548bebe 100644 (file)
@@ -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;
index d435c64a8bab49d5cbea94fc3e001c84123a753a..1341730bf36dcfc7ab574a260c972ad6058b99ad 100644 (file)
@@ -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;
index ec0ee480f69e8db0949c8bf6105422cb9a963d87..5b6dd9d1c1200b4e1190feb03207a2baea7877a4 100644 (file)
@@ -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;
index bb066dc2b84cc06bbf3406fd0b631b93f2ffe22e..c4b75fe991adf9c3f381c71821b6cabdf55d746b 100644 (file)
@@ -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 {
index 2fa50efb375d4ad7bcd57c7a363a8b1dff2aa544..47563d3e92f0ab2efc6437f56264bc2bd7c5d057 100644 (file)
@@ -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;
index 5e19ccc424c987437f4d67f2848bc4e74ffba878..6b3cbcc26ea82058d2c05c7951b1506ff06c146e 100644 (file)
@@ -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);
index 65f11bfc684e40e1465fa83a756e0a4f2349ff00..f00d8b6c9bbb248eb065f06651434b3e9d4a6fd3 100644 (file)
@@ -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));
index 8b268e215f8e7e82d8e79ca10f887af7662764ce..f7515d7432018abd8df46427772e539710fe4869 100644 (file)
@@ -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;
        }
 
index 7e3c21c33eaa9349776407be6f0a29778930c350..1b2a26f446085719aaa2ea47d4aa5cf6e7a3dc35 100644 (file)
@@ -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);
index ffec385cd3b15210c1f7dd9ecb9429268cecf777..5aded17b09ca2b1dc2d1a7644fd319a96ecde499 100644 (file)
@@ -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;
index 8d0703cc7d2634409fd8af409fdf646a3acbd8b0..dc6513252e0af051a6433849fb3b1eadbdb4e391 100644 (file)
@@ -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;
index 2682f7bdb82407b24a53595f04865292c0b3132f..f61d69ae5c5a954f528b4a4c88de90be2e32827c 100644 (file)
@@ -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;
index 78376a45ef1747c2a5e070edd516c278e803bc1c..d48ed4a6ccf8674dd09bb5ee93fa4e6d321d47dd 100644 (file)
@@ -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(&regs[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));
 }
index f51397029719597aeb696cb48b1743fb742faa92..fb0569311a0024811e568b1a2e15dd30bf71507d 100644 (file)
@@ -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,
index 18c02061d4bf020a22e334475f52f361fb906b56..ce9b24d5acb168d5b3d4527a7d25be5d288f25f2 100644 (file)
@@ -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;
index ae1a7f6861d2af2452f450ebee49a9ef5ec7eaf7..4e043c3aedf14cf212fcd64df641671fedca1848 100644 (file)
@@ -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);
index c2083f7bafe91e7f7697b8796cd4171b93ea4fe0..e7fffb869476b20dd6447bb7a46df757e1012a8e 100644 (file)
@@ -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);
index be5d725660f3572f3eea76235f1d129cf48379c6..fb48ef099ea5e8ed90a03b37864d892a0a67ef77 100644 (file)
@@ -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);
index dccd025da360f17b7dc561da539f20c8c23fc384..9b95e18cfef15365921d31d0200e77cbe4ef8334 100644 (file)
@@ -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)
index dea7740c5d811826fc9e9bc8d8bef110f38422e1..1ab19a8d6f212e2a76794562ffe84cfb014cc6d1 100644 (file)
@@ -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;
index 5006380b6374a418a9f18621d0c95d1610365f0c..29ba0fed9980ee4177824a13521e4a29ff97d980 100644 (file)
@@ -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)
index 8bf40c5e22a9edfb84edda6b685f8d03a55a8a98..72f41b4c75cbf70b82a9d1884e5fa7fd2b60bd4c 100644 (file)
@@ -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;
index bd96e3de051b54f0dba011edb97cd70fffa65b59..1131a43d05b87540ef713b12ad95c4467f02d3f4 100644 (file)
@@ -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;
index 1d7eba408bb38ddddd36058d9f49fd2fcc4cb32f..94cab7fbeea63405c7faf6785a7ed0cf5281a3bc 100644 (file)
@@ -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));
 
index 9bbe169f6c781550710e98427e871a5aea843241..66dd9ba53ca91145f52ddd0eaa349607a3887e87 100644 (file)
@@ -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;
index 5a847eb2257c81e342701589f57446f13e414543..f97b07109eae6ffb66e105d764979620934b6bff 100644 (file)
@@ -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;
index 4e4fc3a5af460b5606168f72e76f2b45742dd8c4..127324f2d1489500dcfc0c2e427f09f9fb664e7a 100644 (file)
@@ -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. */
index 6e6413fb9c87babcaa138c33814cd6bbde43e436..dd36f87fc33c9b6f96a6b88b338b97304a5ca113 100644 (file)
@@ -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,
index 4b412fb59a5a287a5b692ada9f166231c3565c20..1c0391f574db34bfcb6fc838bbf37bbb5f2da46e 100644 (file)
@@ -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;
 
index 63ca46f58065474c86136f5923a43e66e0236c30..0f5215a5524e94fd5860f5c80b4db05519c7af8e 100644 (file)
@@ -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;
 
index aa8aca8b896b03043ed0016aa2b32b9861a4a06d..c6d2ae6018cbdce0c0dbfc79c6c9e5fe7accb6af 100644 (file)
@@ -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;
index 5bba8d9bb52085930a835365dc6249ab5d6d8d53..28480f52f1da60bd23e96bdf653cd9125bfec86e 100644 (file)
@@ -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;
index 0dff00d625baf20920460c0ba21733434e6e8f24..1937a71c996929d262a1cb4161e15ce1c37cc64a 100644 (file)
@@ -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;
        }
index af8e62034b1f3a37fedcdc3e940d765d37c0bb32..5f0cd9f08fae3f6e60055bd50f6d592c1abf473e 100644 (file)
@@ -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);
index 02e6dd023df0d1fbc74bba9f0a15ecb450fb788a..9030a4ba7d2c055285d406b113135eef1bd03919 100644 (file)
@@ -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;