]> sigrok.org Git - libsigrok.git/commitdiff
drivers: Fix behaviour when trying to set an invalid capture ratio.
authorTilman Sauerbeck <redacted>
Thu, 15 Oct 2015 20:38:12 +0000 (22:38 +0200)
committerUwe Hermann <redacted>
Sat, 24 Oct 2015 19:10:29 +0000 (21:10 +0200)
Trying to configure an invalid capture ratio would reset the
previously configured value. Instead, we should just reject the
new value and keep the original one.

src/hardware/beaglelogic/api.c
src/hardware/fx2lafw/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/pipistrello-ols/api.c
src/hardware/saleae-logic16/api.c

index 1c8e43b84f55f722142b356547b367cd926a2fe4..b974010468f38dfb440198c150fe6bcb7e486286 100644 (file)
@@ -284,10 +284,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                return beaglelogic_set_triggerflags(devc);
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               if (devc->capture_ratio > 100) {
-                       devc->capture_ratio = 0;
+               if (devc->capture_ratio > 100)
                        return SR_ERR;
-               }
                return SR_OK;
        default:
                return SR_ERR_NA;
index efb1d0d2e37892fd16d0183865f51531f25b1d6d..6376d0fb43103cc64a3ead264c90eaf5510028a7 100644 (file)
@@ -567,11 +567,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               if (devc->capture_ratio > 100) {
-                       devc->capture_ratio = 0;
-                       ret = SR_ERR;
-               } else
-                       ret = SR_OK;
+               ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
                break;
        default:
                ret = SR_ERR_NA;
index e61bd10d394e034bc97fcb951b2663b3ed8ce0a4..fe442ac60bd8c1abbd12c33e28c8f2ff3b2db2b2 100644 (file)
@@ -291,10 +291,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               if (devc->capture_ratio < 0 || devc->capture_ratio > 100) {
-                       devc->capture_ratio = 0;
+               if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
                        ret = SR_ERR;
-               else
+               else
                        ret = SR_OK;
                break;
        case SR_CONF_EXTERNAL_CLOCK:
index c467f0cc13197335a9b8e81ca5906deb19a73856..44af4017077d8d79f4503fa1d720ed0678381cc6 100644 (file)
@@ -299,10 +299,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               if (devc->capture_ratio < 0 || devc->capture_ratio > 100) {
-                       devc->capture_ratio = 0;
+               if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
                        ret = SR_ERR;
-               else
+               else
                        ret = SR_OK;
                break;
        case SR_CONF_EXTERNAL_CLOCK:
index 43477d5b04d10d1dab244711128fa80d1ac158be..bee0ea4ad95f30a755fcc00463b7d587f34c0b60 100644 (file)
@@ -502,11 +502,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               if (devc->capture_ratio > 100) {
-                       devc->capture_ratio = 0;
-                       ret = SR_ERR;
-               } else
-                       ret = SR_OK;
+               ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
                break;
        case SR_CONF_VOLTAGE_THRESHOLD:
                g_variant_get(data, "(dd)", &low, &high);