Skip to content

Commit

Permalink
jtag: Use 'unsigned int' for 'ir_length'
Browse files Browse the repository at this point in the history
This patch modifies as little code as possible in order to simplify the
review. Data types that are affected by these changes will be modified
in following patches.

Change-Id: I83921d70e017095d63547e0bc9fe61779191d9d0
Signed-off-by: Marc Schink <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/8403
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
  • Loading branch information
zapb-0 authored and borneoa committed Aug 2, 2024
1 parent 4fac138 commit 4245034
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/jtag/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ static int jtag_validate_ircapture(void)
&& tap->ir_length < JTAG_IRLEN_MAX) {
tap->ir_length++;
}
LOG_WARNING("AUTO %s - use \"jtag newtap %s %s -irlen %d "
LOG_WARNING("AUTO %s - use \"jtag newtap %s %s -irlen %u "
"-expected-id 0x%08" PRIx32 "\"",
tap->dotted_name, tap->chip, tap->tapname, tap->ir_length, tap->idcode);
}
Expand Down Expand Up @@ -1472,7 +1472,7 @@ void jtag_tap_init(struct jtag_tap *tap)
jtag_tap_add(tap);

LOG_DEBUG("Created Tap: %s @ abs position %u, "
"irlen %d, capture: 0x%x mask: 0x%x", tap->dotted_name,
"irlen %u, capture: 0x%x mask: 0x%x", tap->dotted_name,
tap->abs_chain_position, tap->ir_length,
(unsigned) tap->ir_capture_value,
(unsigned) tap->ir_capture_mask);
Expand Down
2 changes: 1 addition & 1 deletion src/jtag/jtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct jtag_tap {
bool disabled_after_reset;
/** Is this TAP currently enabled? */
bool enabled;
int ir_length; /**< size of instruction register */
unsigned int ir_length; /**< size of instruction register */
uint32_t ir_capture_value;
uint8_t *expected; /**< Capture-IR expected value */
uint32_t ir_capture_mask;
Expand Down
12 changes: 6 additions & 6 deletions src/jtag/tcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ static COMMAND_HELPER(handle_jtag_newtap_args, struct jtag_tap *tap)
if (!CMD_ARGC)
return ERROR_COMMAND_ARGUMENT_INVALID;

COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tap->ir_length);
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], tap->ir_length);
CMD_ARGC--;
CMD_ARGV++;
if (tap->ir_length > (int)(8 * sizeof(tap->ir_capture_value)))
LOG_WARNING("%s: huge IR length %d", tap->dotted_name, tap->ir_length);
if (tap->ir_length > (8 * sizeof(tap->ir_capture_value)))
LOG_WARNING("%s: huge IR length %u", tap->dotted_name, tap->ir_length);
break;

case NTAP_OPT_IRMASK:
Expand Down Expand Up @@ -814,13 +814,13 @@ COMMAND_HANDLER(handle_scan_chain_command)
expected_mask = buf_get_u32(tap->expected_mask, 0, tap->ir_length);

command_print(CMD,
"%2u %-18s %c 0x%08x %s %5d 0x%02x 0x%02x",
"%2u %-18s %c 0x%08x %s %5u 0x%02x 0x%02x",
tap->abs_chain_position,
tap->dotted_name,
tap->enabled ? 'Y' : 'n',
(unsigned int)(tap->idcode),
expected_id,
(unsigned int)(tap->ir_length),
tap->ir_length,
(unsigned int)(expected),
(unsigned int)(expected_mask));

Expand Down Expand Up @@ -972,7 +972,7 @@ COMMAND_HANDLER(handle_irscan_command)
if (retval != ERROR_OK)
goto error_return;

int field_size = tap->ir_length;
unsigned int field_size = tap->ir_length;
fields[i].num_bits = field_size;
uint8_t *v = calloc(1, DIV_ROUND_UP(field_size, 8));
if (!v) {
Expand Down
2 changes: 1 addition & 1 deletion src/target/avrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out,
LOG_ERROR("invalid tap");
return ERROR_FAIL;
}
if (ir_len != tap->ir_length) {
if ((unsigned int)ir_len != tap->ir_length) {
LOG_ERROR("invalid ir_len");
return ERROR_FAIL;
}
Expand Down
4 changes: 2 additions & 2 deletions src/target/lakemont.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ static int irscan(struct target *t, uint8_t *out,
if (ir_len != t->tap->ir_length) {
retval = ERROR_FAIL;
if (t->tap->enabled)
LOG_ERROR("%s tap enabled but tap irlen=%d",
LOG_ERROR("%s tap enabled but tap irlen=%u",
__func__, t->tap->ir_length);
else
LOG_ERROR("%s tap not enabled and irlen=%d",
LOG_ERROR("%s tap not enabled and irlen=%u",
__func__, t->tap->ir_length);
return retval;
}
Expand Down

0 comments on commit 4245034

Please sign in to comment.