]> git.gag.com Git - fw/openocd/commitdiff
jtag/core: fix unused assignment
authorAntonio Borneo <borneo.antonio@gmail.com>
Wed, 22 Sep 2021 16:39:57 +0000 (18:39 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Mon, 25 Oct 2021 16:08:41 +0000 (16:08 +0000)
Clang scan-build complains about a variable assigned but never
used.
Although the value stored to 'val' is used in the
enclosing expression, the value is never actually read
from 'val'

Remove the dead assignment. While there, reduce the scope of the
variable by declaring the variable at the point of first use.

Change-Id: Ibe2b55a7d70597833cfa7f3d843e7c3d2407f2df
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6587
Tested-by: jenkins
src/jtag/core.c

index 7da2a6c35fdbc396e6752bd4c377cfbbb4346353..51875a00a78260c486b1747615bee4b47c146d5b 100644 (file)
@@ -1336,7 +1336,6 @@ static int jtag_validate_ircapture(void)
        struct jtag_tap *tap;
        uint8_t *ir_test = NULL;
        struct scan_field field;
-       uint64_t val;
        int chain_pos = 0;
        int retval;
 
@@ -1396,7 +1395,7 @@ static int jtag_validate_ircapture(void)
                 */
                if (tap->ir_length == 0) {
                        tap->ir_length = 2;
-                       while ((val = buf_get_u64(ir_test, chain_pos, tap->ir_length + 1)) == 1
+                       while (buf_get_u64(ir_test, chain_pos, tap->ir_length + 1) == 1
                                        && tap->ir_length < JTAG_IRLEN_MAX) {
                                tap->ir_length++;
                        }
@@ -1412,7 +1411,7 @@ static int jtag_validate_ircapture(void)
                 * this part of the JTAG spec, so their capture mask/value
                 * attributes might disable this test.
                 */
-               val = buf_get_u64(ir_test, chain_pos, tap->ir_length);
+               uint64_t val = buf_get_u64(ir_test, chain_pos, tap->ir_length);
                if ((val & tap->ir_capture_mask) != tap->ir_capture_value) {
                        LOG_ERROR("%s: IR capture error; saw 0x%0*" PRIx64 " not 0x%0*" PRIx32,
                                jtag_tap_name(tap),
@@ -1428,7 +1427,7 @@ static int jtag_validate_ircapture(void)
        }
 
        /* verify the '11' sentinel we wrote is returned at the end */
-       val = buf_get_u64(ir_test, chain_pos, 2);
+       uint64_t val = buf_get_u64(ir_test, chain_pos, 2);
        if (val != 0x3) {
                char *cbuf = buf_to_hex_str(ir_test, total_ir_length);