From: Bert Vermeulen Date: Sat, 30 Mar 2013 14:28:28 +0000 (+0100) Subject: avoid deprecated struct sr_rational X-Git-Tag: sigrok-cli-0.4.0~20 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bd31fc3fb35bf317aabe5692aec3d0062cfb8e11;p=sigrok-cli.git avoid deprecated struct sr_rational --- diff --git a/sigrok-cli.c b/sigrok-cli.c index 8cfdb8e..f4a899c 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -1424,10 +1424,9 @@ static int set_dev_options(struct sr_dev_inst *sdi, GHashTable *args) gpointer key, value; int ret; float tmp_float; - uint64_t tmp_u64; - struct sr_rational tmp_rat; + uint64_t tmp_u64, p, q; gboolean tmp_bool; - void *val; + GVariant *val, *rational[2]; g_hash_table_iter_init(&iter, args); while (g_hash_table_iter_next(&iter, &key, &value)) { @@ -1464,14 +1463,18 @@ static int set_dev_options(struct sr_dev_inst *sdi, GHashTable *args) val = &tmp_float; break; case SR_T_RATIONAL_PERIOD: - if ((ret = sr_parse_period(value, &tmp_rat)) != SR_OK) + if ((ret = sr_parse_period(value, &p, &q)) != SR_OK) break; - val = &tmp_rat; + rational[0] = g_variant_new_uint64(p); + rational[1] = g_variant_new_uint64(q); + val = g_variant_new_tuple(rational, 2); break; case SR_T_RATIONAL_VOLT: - if ((ret = sr_parse_voltage(value, &tmp_rat)) != SR_OK) + if ((ret = sr_parse_voltage(value, &p, &q)) != SR_OK) break; - val = &tmp_rat; + rational[0] = g_variant_new_uint64(p); + rational[1] = g_variant_new_uint64(q); + val = g_variant_new_tuple(rational, 2); break; default: ret = SR_ERR;