From: Antonio Borneo Date: Wed, 22 Sep 2021 16:39:57 +0000 (+0200) Subject: jtag/core: fix unused assignment X-Git-Tag: v0.12.0-rc1~482 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=b3f052ba9d9582fe203ff8baa73fef66c02196ac;ds=sidebyside jtag/core: fix unused assignment 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 Reviewed-on: https://review.openocd.org/c/openocd/+/6587 Tested-by: jenkins --- diff --git a/src/jtag/core.c b/src/jtag/core.c index 7da2a6c35f..51875a00a7 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -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);