]> sigrok.org Git - libsigrok.git/commitdiff
ols, pipistrello-ols: silence "assigned, not used" compiler warning
authorGerhard Sittig <redacted>
Fri, 9 Feb 2018 18:23:31 +0000 (19:23 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 20:37:39 +0000 (21:37 +0100)
Each code path either assigns to 'flags', or leaves the routine. There
is no potential path that leaves the variable at the initially assigned
value, so the assignment took no effect. Remove it.

Nit: Trim the source code line length while we are here.

This was reported by clang's scan-build.

src/hardware/openbench-logic-sniffer/api.c
src/hardware/pipistrello-ols/api.c

index d15cb12cfa425e1a5664abdb6081726ef6e34652..fc0d9ebdb3afe6813e7e3e26fed2258dc449e37d 100644 (file)
@@ -265,7 +265,6 @@ static int config_set(uint32_t key, GVariant *data,
                break;
        case SR_CONF_PATTERN_MODE:
                stropt = g_variant_get_string(data, NULL);
-               flag = 0xffff;
                if (!strcmp(stropt, STR_PATTERN_NONE)) {
                        sr_info("Disabling test modes.");
                        flag = 0x0000;
@@ -278,10 +277,9 @@ static int config_set(uint32_t key, GVariant *data,
                } else {
                        return SR_ERR;
                }
-               if (flag != 0xffff) {
-                       devc->flag_reg &= ~(FLAG_INTERNAL_TEST_MODE | FLAG_EXTERNAL_TEST_MODE);
-                       devc->flag_reg |= flag;
-               }
+               devc->flag_reg &= ~FLAG_INTERNAL_TEST_MODE;
+               devc->flag_reg &= ~FLAG_EXTERNAL_TEST_MODE;
+               devc->flag_reg |= flag;
                break;
        case SR_CONF_SWAP:
                if (g_variant_get_boolean(data)) {
index 1d1388bae3bdc174488dc58677132ea5743498e2..33339d6bcc86eb7250c5ff9b0880cd0a29d66fb4 100644 (file)
@@ -276,7 +276,6 @@ static int config_set(uint32_t key, GVariant *data,
                break;
        case SR_CONF_PATTERN_MODE:
                stropt = g_variant_get_string(data, NULL);
-               flag = 0xffff;
                if (!strcmp(stropt, STR_PATTERN_NONE)) {
                        sr_info("Disabling test modes.");
                        flag = 0x0000;
@@ -289,10 +288,9 @@ static int config_set(uint32_t key, GVariant *data,
                } else {
                        return SR_ERR;
                }
-               if (flag != 0xffff) {
-                       devc->flag_reg &= ~(FLAG_INTERNAL_TEST_MODE | FLAG_EXTERNAL_TEST_MODE);
-                       devc->flag_reg |= flag;
-               }
+               devc->flag_reg &= ~FLAG_INTERNAL_TEST_MODE;
+               devc->flag_reg &= ~FLAG_EXTERNAL_TEST_MODE;
+               devc->flag_reg |= flag;
                break;
        case SR_CONF_SWAP:
                if (g_variant_get_boolean(data)) {