]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hantek-dso/api.c
drivers: Use g_variant_new_printf() where possible.
[libsigrok.git] / src / hardware / hantek-dso / api.c
index 651c0e6125ee8dba068c85be9308ca5d7c7c5c1a..22788e0eb6f14a8722e44c1eeda95ca4ae14fc2e 100644 (file)
@@ -392,12 +392,11 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_get(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
-       char str[128];
        const char *s;
        const uint64_t *vdiv;
        int ch_idx;
@@ -425,8 +424,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                                /* Device still needs to re-enumerate after firmware
                                 * upload, so we don't know its (future) address. */
                                return SR_ERR;
-                       snprintf(str, 128, "%d.%d", usb->bus, usb->address);
-                       *data = g_variant_new_string(str);
+                       *data = g_variant_new_printf("%d.%d", usb->bus, usb->address);
                        break;
                case SR_CONF_TIMEBASE:
                        *data = g_variant_new("(tt)", timebases[devc->timebase][0],
@@ -472,8 +470,8 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
        return SR_OK;
 }
 
-static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_set(uint32_t key, GVariant *data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
        double tmp_double;
@@ -586,8 +584,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        return SR_OK;
 }
 
-static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_list(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
 
@@ -603,7 +601,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 +621,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;