]> sigrok.org Git - libsigrok.git/commitdiff
siglent-sds: Fix SR_CONF_TRIGGER_SLOPE config_set() code.
authorUwe Hermann <redacted>
Fri, 16 Feb 2018 23:44:55 +0000 (00:44 +0100)
committerUwe Hermann <redacted>
Fri, 16 Feb 2018 23:51:53 +0000 (00:51 +0100)
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

index e526bc2f8ed4c8f4d82cbc18fe69c7ff150c5f16..2d0a6b95394ade3395f14c59e30a7522762c5128 100644 (file)
@@ -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;