From: Uwe Hermann Date: Tue, 25 Jul 2017 19:50:24 +0000 (+0200) Subject: drivers: Use g_variant_new_printf() where possible. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=95c1fe62f77d347bf173b1236c38a9043efabd2b;p=libsigrok.git drivers: Use g_variant_new_printf() where possible. --- diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index 0a1a2232..94b5b42a 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -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) diff --git a/src/hardware/dreamsourcelab-dslogic/api.c b/src/hardware/dreamsourcelab-dslogic/api.c index d7e1b15f..65732d3a 100644 --- a/src/hardware/dreamsourcelab-dslogic/api.c +++ b/src/hardware/dreamsourcelab-dslogic/api.c @@ -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")) { diff --git a/src/hardware/ftdi-la/api.c b/src/hardware/ftdi-la/api.c index 15472f82..1a6c3f35 100644 --- a/src/hardware/ftdi-la/api.c +++ b/src/hardware/ftdi-la/api.c @@ -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; diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index bffd2534..28b82de9 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -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); diff --git a/src/hardware/hantek-6xxx/api.c b/src/hardware/hantek-6xxx/api.c index a7b13185..c5bb94eb 100644 --- a/src/hardware/hantek-6xxx/api.c +++ b/src/hardware/hantek-6xxx/api.c @@ -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; diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index 27f4f64f..22788e0e 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -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], diff --git a/src/hardware/lascar-el-usb/api.c b/src/hardware/lascar-el-usb/api.c index aacc3ead..b5d73b23 100644 --- a/src/hardware/lascar-el-usb/api.c +++ b/src/hardware/lascar-el-usb/api.c @@ -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) diff --git a/src/hardware/saleae-logic16/api.c b/src/hardware/saleae-logic16/api.c index ecb2953b..00a4c1bc 100644 --- a/src/hardware/saleae-logic16/api.c +++ b/src/hardware/saleae-logic16/api.c @@ -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) diff --git a/src/hardware/testo/api.c b/src/hardware/testo/api.c index 6df56e1b..90fb65ca 100644 --- a/src/hardware/testo/api.c +++ b/src/hardware/testo/api.c @@ -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: diff --git a/src/hardware/victor-dmm/api.c b/src/hardware/victor-dmm/api.c index d03c6398..6a9b774f 100644 --- a/src/hardware/victor-dmm/api.c +++ b/src/hardware/victor-dmm/api.c @@ -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: