Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data types around batch.{c,h} #1202

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

JanMatCodasip
Copy link
Collaborator

@JanMatCodasip JanMatCodasip commented Jan 8, 2025

Check that the value of dtmcs.abits is in the expected range
during the target examination.

Make corrections of data types in batch.{c,h} and in related code.
Some of the issues were found by activating "-Wconversion" in GCC,
others by inspecting the code manually.

This is an initial step towards being able to use "-Wconversion" on
RISC-V target code, which will give us bit more confidence around
data types when refactoring or merging new patches.

en-sc
en-sc previously approved these changes Jan 15, 2025
Copy link
Collaborator

@en-sc en-sc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

A couple of minor nitpicks.

src/target/riscv/batch.c Outdated Show resolved Hide resolved
src/target/riscv/riscv-013.c Outdated Show resolved Hide resolved
en-sc
en-sc previously approved these changes Jan 20, 2025
Copy link
Collaborator

@en-sc en-sc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!
IMHO it can be merged as-is, although I have a couple suggestion. Please take a look.

src/target/riscv/riscv-013.c Outdated Show resolved Hide resolved
src/target/riscv/batch.c Outdated Show resolved Hide resolved
src/target/riscv/batch.c Outdated Show resolved Hide resolved
Check that the value of dtmcs.abits is in the expected range.

Make corrections of data types in batch.{c,h} and in related code.
Some of the issues were found by activating "-Wconversion" in GCC,
others by inspecting the code manually.

This is an initial step towards being able to use "-Wconversion" on
RISC-V target code, which will give us bit more confidence when
refactoring or merging new patches.

Changes made:

- Check `dtmcs.abits` during examination.

- DMI address is no larger than 32-bits per the debug spec.
  Changed address parameters of multiple functions from uint64_t
  to uint32_t.

- The value passed to jtag_add_runtest() is now `unsigned int`,
  not `int`. No need for `assert(idle <= INT_MAX)` anymore.

- `get_delay()` in batch.c can return an unsigned value.

- Added few assertions around `field->num_bits` in batch.c.

Change-Id: Ibfccd62d552063df6ab9b5a2d4ea4ed23617d3db
Signed-off-by: Jan Matyas <[email protected]>
Copy link
Collaborator

@en-sc en-sc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks a lot for this cleanup!

@en-sc en-sc merged commit 57b58b7 into riscv-collab:riscv Jan 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants