From 2dedd64e116c86908d6106f232edbb4773cc4482 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 17 Feb 2018 00:44:55 +0100 Subject: [PATCH] siglent-sds: Fix SR_CONF_TRIGGER_SLOPE config_set() code. Also use "r" and "f" as trigger slope values for now, since that's what most other drivers do currently. This also fixes two scan-build issues: api.c:559:3: warning: Value stored to 'tmp_str' is never read tmp_str = g_variant_get_string(data, NULL); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ api.c:561:9: warning: Use of memory after it is freed ret = siglent_sds_config_set(sdi, "%s:TRSL %s", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/hardware/siglent-sds/api.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hardware/siglent-sds/api.c b/src/hardware/siglent-sds/api.c index e526bc2f..2d0a6b95 100644 --- a/src/hardware/siglent-sds/api.c +++ b/src/hardware/siglent-sds/api.c @@ -134,7 +134,7 @@ static const char *trigger_sources[] = { }; static const char *trigger_slopes[] = { - "Rising", "Falling", + "r", "f", }; static const char *coupling[] = { @@ -534,7 +534,7 @@ static int config_set(uint32_t key, GVariant *data, uint64_t p, q; double t_dbl; unsigned int i, j; - int ret; + int ret, idx; const char *tmp_str; char buffer[16]; @@ -555,8 +555,10 @@ static int config_set(uint32_t key, GVariant *data, devc->limit_frames = g_variant_get_uint64(data); break; case SR_CONF_TRIGGER_SLOPE: - tmp_str = g_variant_get_string(data, NULL); + if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_slopes))) < 0) + return SR_ERR_ARG; g_free(devc->trigger_slope); + devc->trigger_slope = g_strdup((trigger_slopes[idx][0] == 'r') ? "POS" : "NEG"); ret = siglent_sds_config_set(sdi, "%s:TRSL %s", devc->trigger_source, devc->trigger_slope); break;