]> sigrok.org Git - libsigrok.git/commitdiff
std_gvar_tuple_array(): Change to allow for more ARRAY_AND_SIZE usage.
authorUwe Hermann <redacted>
Fri, 21 Jul 2017 16:45:42 +0000 (18:45 +0200)
committerUwe Hermann <redacted>
Fri, 21 Jul 2017 17:04:34 +0000 (19:04 +0200)
Thanks to Marcus Comstedt <redacted> for the hint!

src/hardware/cem-dt-885x/api.c
src/hardware/hameg-hmo/api.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/pce-322a/api.c
src/hardware/rigol-ds/api.c
src/hardware/yokogawa-dlm/api.c
src/libsigrok-internal.h
src/std.c

index d7a75b6003e372cbb3a5e8806733f15293565a8d..2493a535f3877259c37c68409eda50e1b3fb4742 100644 (file)
@@ -295,7 +295,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *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));
+               *data = std_gvar_tuple_array(ARRAY_AND_SIZE(meas_ranges));
                break;
        case SR_CONF_DATA_SOURCE:
                *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
index c4b75fe991adf9c3f381c71821b6cabdf55d746b..1e424440bd4e900aea6fbe956e98b91ee55ac4cb 100644 (file)
@@ -495,12 +495,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        case SR_CONF_TIMEBASE:
                if (!model)
                        return SR_ERR_ARG;
-               *data = std_gvar_tuple_array(model->timebases, model->num_timebases);
+               *data = std_gvar_tuple_array(*model->timebases, model->num_timebases);
                break;
        case SR_CONF_VDIV:
                if (cg_type == CG_NONE)
                        return SR_ERR_CHANNEL_GROUP;
-               *data = std_gvar_tuple_array(model->vdivs, model->num_vdivs);
+               *data = std_gvar_tuple_array(*model->vdivs, model->num_vdivs);
                break;
        default:
                return SR_ERR_NA;
index 6b3cbcc26ea82058d2c05c7951b1506ff06c146e..53f505989b037baae4dc2fda33812b76225aab7b 100644 (file)
@@ -482,7 +482,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        *data = g_variant_new_strv(devc->coupling_vals, devc->coupling_tab_size);
                        break;
                case SR_CONF_VDIV:
-                       *data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs));
+                       *data = std_gvar_tuple_array(ARRAY_AND_SIZE(vdivs));
                        break;
                default:
                        return SR_ERR_NA;
index 651c0e6125ee8dba068c85be9308ca5d7c7c5c1a..78b7f3b304e7d725733c53f9b70485e1c9cc4fa9 100644 (file)
@@ -603,7 +603,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        *data = std_gvar_array_u64(devc->profile->buffersizes, NUM_BUFFER_SIZES);
                        break;
                case SR_CONF_TIMEBASE:
-                       *data = std_gvar_tuple_array(&timebases, ARRAY_SIZE(timebases));
+                       *data = std_gvar_tuple_array(ARRAY_AND_SIZE(timebases));
                        break;
                case SR_CONF_TRIGGER_SOURCE:
                        *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_sources));
@@ -623,7 +623,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        *data = g_variant_new_strv(ARRAY_AND_SIZE(coupling));
                        break;
                case SR_CONF_VDIV:
-                       *data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs));
+                       *data = std_gvar_tuple_array(ARRAY_AND_SIZE(vdivs));
                        break;
                default:
                        return SR_ERR_NA;
index f7515d7432018abd8df46427772e539710fe4869..5c764e45ded318d7988071b9cf843314ece6f746 100644 (file)
@@ -604,7 +604,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = std_gvar_array_u64(ARRAY_AND_SIZE(buffersizes));
                break;
        case SR_CONF_VDIV:
-               *data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs));
+               *data = std_gvar_tuple_array(ARRAY_AND_SIZE(vdivs));
                break;
        case SR_CONF_COUPLING:
                *data = g_variant_new_strv(ARRAY_AND_SIZE(coupling));
index 50986802c4fec034ea6ac4c6ff78ce0f02b65380..9fb9a0a74939158054bac5009a09a34d7e51e98e 100644 (file)
@@ -324,8 +324,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_SAMPLE_INTERVAL:
-               *data = std_gvar_tuple_array(&kecheng_kc_330b_sample_intervals,
-                               ARRAY_SIZE(kecheng_kc_330b_sample_intervals));
+               *data = std_gvar_tuple_array(ARRAY_AND_SIZE(kecheng_kc_330b_sample_intervals));
                break;
        case SR_CONF_SPL_WEIGHT_FREQ:
                *data = g_variant_new_strv(ARRAY_AND_SIZE(weight_freq));
index 04a8cfba407c98ad4f2a8c6757c6cbc88f6f20e9..9e45e72de27c4c2aec7086ae0bf8c909b1138634 100644 (file)
@@ -247,7 +247,7 @@ static int config_list(uint32_t key, GVariant **data,
                *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));
+               *data = std_gvar_tuple_array(ARRAY_AND_SIZE(meas_ranges));
                break;
        case SR_CONF_DATA_SOURCE:
                *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources));
index 740e11f7f1f13dac681f2e3f83d7a24f842d94a5..c2661a45ba96a7ee8d4dca5a4c48a1e615e64f92 100644 (file)
@@ -840,7 +840,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        return SR_ERR_ARG;
                if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
-               *data = std_gvar_tuple_array((const uint64_t (*)[][2])devc->vdivs, devc->num_vdivs);
+               *data = std_gvar_tuple_array(devc->vdivs, devc->num_vdivs);
                break;
        case SR_CONF_TIMEBASE:
                if (!devc)
@@ -848,7 +848,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        return SR_ERR_ARG;
                if (devc->num_timebases <= 0)
                        return SR_ERR_NA;
-               *data = std_gvar_tuple_array((const uint64_t (*)[][2])devc->timebases, devc->num_timebases);
+               *data = std_gvar_tuple_array(devc->timebases, devc->num_timebases);
                break;
        case SR_CONF_TRIGGER_SOURCE:
                if (!devc)
index 87b0c7764979bb0231cf6cd358f8307c3a7f7e0d..4cdec52aa0c4e95b0534fd274a81e4acf2e708d1 100644 (file)
@@ -462,7 +462,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_TIMEBASE:
-                       *data = std_gvar_tuple_array(&dlm_timebases, ARRAY_SIZE(dlm_timebases));
+                       *data = std_gvar_tuple_array(ARRAY_AND_SIZE(dlm_timebases));
                        return SR_OK;
                case SR_CONF_TRIGGER_SOURCE:
                        if (!model)
@@ -503,7 +503,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        case SR_CONF_VDIV:
                if (cg_type == CG_NONE)
                        return SR_ERR_CHANNEL_GROUP;
-               *data = std_gvar_tuple_array(&dlm_vdivs, ARRAY_SIZE(dlm_vdivs));
+               *data = std_gvar_tuple_array(ARRAY_AND_SIZE(dlm_vdivs));
                break;
        default:
                return SR_ERR_NA;
index cb0e38f3596760263ed874dad13b6d8efe3b1a49..1df5311cec776d6973462d1eb6429c210d70c70e 100644 (file)
@@ -956,7 +956,7 @@ SR_PRIV int std_opts_config_list(uint32_t key, GVariant **data,
        std_opts_config_list(key, data, sdi, cg, ARRAY_AND_SIZE(scanopts), \
                ARRAY_AND_SIZE(drvopts), ARRAY_AND_SIZE(devopts))
 
-SR_PRIV GVariant *std_gvar_tuple_array(const uint64_t (*a)[][2], unsigned int n);
+SR_PRIV GVariant *std_gvar_tuple_array(const uint64_t a[][2], unsigned int n);
 SR_PRIV GVariant *std_gvar_tuple_rational(const struct sr_rational *r, unsigned int n);
 SR_PRIV GVariant *std_gvar_samplerates(const uint64_t samplerates[], unsigned int n);
 SR_PRIV GVariant *std_gvar_samplerates_steps(const uint64_t samplerates[], unsigned int n);
index 119b301ee0d9083312d3eb043de901bd5f5aeb54..fa4218e67ace8f61c61e2dd6912b632438cb0385 100644 (file)
--- a/src/std.c
+++ b/src/std.c
@@ -541,7 +541,7 @@ SR_PRIV int std_opts_config_list(uint32_t key, GVariant **data,
        return SR_OK;
 }
 
-SR_PRIV GVariant *std_gvar_tuple_array(const uint64_t (*a)[][2], unsigned int n)
+SR_PRIV GVariant *std_gvar_tuple_array(const uint64_t a[][2], unsigned int n)
 {
        unsigned int i;
        GVariant *rational[2];
@@ -550,8 +550,8 @@ SR_PRIV GVariant *std_gvar_tuple_array(const uint64_t (*a)[][2], unsigned int n)
        g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
 
        for (i = 0; i < n; i++) {
-               rational[0] = g_variant_new_uint64((*a)[i][0]);
-               rational[1] = g_variant_new_uint64((*a)[i][1]);
+               rational[0] = g_variant_new_uint64(a[i][0]);
+               rational[1] = g_variant_new_uint64(a[i][1]);
 
                /* FIXME: Valgrind reports a memory leak here. */
                g_variant_builder_add_value(&gvb, g_variant_new_tuple(rational, 2));