drivers: Use g_variant_new_printf() where possible.
This commit is contained in:
parent
9fb9afb573
commit
95c1fe62f7
|
@ -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)
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue