]> sigrok.org Git - libsigrok.git/commitdiff
drivers: Use g_variant_new_printf() where possible.
authorUwe Hermann <redacted>
Tue, 25 Jul 2017 19:50:24 +0000 (21:50 +0200)
committerUwe Hermann <redacted>
Mon, 31 Jul 2017 14:23:31 +0000 (16:23 +0200)
src/hardware/chronovu-la/api.c
src/hardware/dreamsourcelab-dslogic/api.c
src/hardware/ftdi-la/api.c
src/hardware/fx2lafw/api.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/lascar-el-usb/api.c
src/hardware/saleae-logic16/api.c
src/hardware/testo/api.c
src/hardware/victor-dmm/api.c

index 0a1a22327a2f82e266237cfbea0286e1015c1981..94b5b42a04b213335c48418ae8367059b882d349 100644 (file)
@@ -288,7 +288,6 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
-       char str[128];
 
        (void)cg;
 
@@ -296,8 +295,7 @@ static int config_get(uint32_t key, GVariant **data,
        case SR_CONF_CONN:
                if (!sdi || !(usb = sdi->conn))
                        return SR_ERR_ARG;
-               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_SAMPLERATE:
                if (!sdi)
index d7e1b15f1eb5366ae8b2fe4f49663302b66ecc15..65732d3a29875805581ce4c1c3faef10d2f60f00 100644 (file)
@@ -381,7 +381,6 @@ static int config_get(uint32_t key, GVariant **data,
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
        unsigned int i, voltage_range;
-       char str[128];
 
        (void)cg;
 
@@ -399,8 +398,7 @@ static int config_get(uint32_t key, GVariant **data,
                        /* 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_VOLTAGE_THRESHOLD:
                if (!strcmp(devc->profile->model, "DSLogic")) {
index 15472f8262250b5ba48f5231c696e333d19aaa47..1a6c3f3556ab81fca081659357c95371a59e3a78 100644 (file)
@@ -310,7 +310,6 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
-       char str[128];
 
        (void)cg;
 
@@ -324,8 +323,7 @@ static int config_get(uint32_t key, GVariant **data,
                if (!sdi || !sdi->conn)
                        return SR_ERR_ARG;
                usb = sdi->conn;
-               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;
        default:
                return SR_ERR_NA;
index bffd2534f60f1121dea408240be3a5fe50391447..28b82de937a5cd966477c47dfd586416d08e269e 100644 (file)
@@ -449,7 +449,6 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
-       char str[128];
 
        (void)cg;
 
@@ -467,8 +466,7 @@ static int config_get(uint32_t key, GVariant **data,
                        /* 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_LIMIT_SAMPLES:
                *data = g_variant_new_uint64(devc->limit_samples);
index a7b131854472d779e766820f02b79a9f529bd27e..c5bb94eb9958a9a278353f13be543164c8dd2cf0 100644 (file)
@@ -327,7 +327,6 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
-       char str[128];
        const uint64_t *vdiv;
        int ch_idx;
 
@@ -360,8 +359,7 @@ static int config_get(uint32_t key, GVariant **data,
                                /* 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;
                default:
                        return SR_ERR_NA;
index 27f4f64f21f04956477327fc60a883e778f344c5..22788e0eb6f14a8722e44c1eeda95ca4ae14fc2e 100644 (file)
@@ -397,7 +397,6 @@ static int config_get(uint32_t key, GVariant **data,
 {
        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,
                                /* 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],
index aacc3ead108b2e9270d8562ac3e8011fb8188aea..b5d73b2382472e5e7896f61a541ff470c3398184 100644 (file)
@@ -126,7 +126,6 @@ static int config_get(uint32_t key, GVariant **data,
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
        int ret;
-       char str[128];
 
        (void)cg;
 
@@ -136,8 +135,7 @@ static int config_get(uint32_t key, GVariant **data,
                if (!sdi || !sdi->conn)
                        return SR_ERR_ARG;
                usb = sdi->conn;
-               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_DATALOG:
                if (!sdi)
index ecb2953b1b56616105564c881378e5076da9293d..00a4c1bc9b87d0d045ef887a0a5bf35e301ea985 100644 (file)
@@ -403,7 +403,6 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
-       char str[128];
        int ret;
        unsigned int i;
 
@@ -419,8 +418,7 @@ static int config_get(uint32_t key, GVariant **data,
                        /* 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_SAMPLERATE:
                if (!sdi)
index 6df56e1b115a7b9db3ba6fa05db273af682bc7e0..90fb65ca4bed4a11f0c3296d766ca57a4f3947c2 100644 (file)
@@ -189,7 +189,6 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct dev_context *devc = sdi->priv;
        struct sr_usb_dev_inst *usb;
-       char str[128];
 
        (void)cg;
 
@@ -198,8 +197,7 @@ static int config_get(uint32_t key, GVariant **data,
                if (!sdi || !sdi->conn)
                        return SR_ERR_ARG;
                usb = sdi->conn;
-               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_LIMIT_MSEC:
        case SR_CONF_LIMIT_SAMPLES:
index d03c63980b9a5ba95cb661704fde199ad06e1a00..6a9b774fc98d6988a8e4b2f0083585cdd9a1e170 100644 (file)
@@ -142,7 +142,6 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct dev_context *devc = sdi->priv;
        struct sr_usb_dev_inst *usb;
-       char str[128];
 
        (void)cg;
 
@@ -151,8 +150,7 @@ static int config_get(uint32_t key, GVariant **data,
                if (!sdi || !sdi->conn)
                        return SR_ERR_ARG;
                usb = sdi->conn;
-               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_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC: