drivers: Use g_variant_new_printf() where possible.

This commit is contained in:
Uwe Hermann 2017-07-25 21:50:24 +02:00
parent 9fb9afb573
commit 95c1fe62f7
10 changed files with 10 additions and 30 deletions

View 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)

View 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")) {

View 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;

View 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);

View 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;

View 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],

View 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)

View 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)

View 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:

View 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: