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 <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6587
Tested-by: jenkins
This commit is contained in:
Antonio Borneo 2021-09-22 18:39:57 +02:00
parent 9188115296
commit b3f052ba9d
1 changed files with 3 additions and 4 deletions

View 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);