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 printf formats #4026

Merged
merged 1 commit into from
Jan 15, 2024
Merged

Fix printf formats #4026

merged 1 commit into from
Jan 15, 2024

Conversation

uis246
Copy link
Contributor

@uis246 uis246 commented Nov 11, 2023

Just what compiler found. Uses proper types like %zu for size_t and %PRIx64 for uint64_t in hexadecimal.

@uis246 uis246 requested a review from zachjs as a code owner November 11, 2023 14:42
@@ -690,7 +690,7 @@ bool apply_clock(MemConfig &cfg, const PortVariant &def, SigBit clk, bool clk_po

// Perform write port assignment, validating clock options as we go.
void MemMapping::assign_wr_ports() {
log_reject(stringf("Assigning write ports... (candidate configs: %lu)", cfgs.size()));
log_reject(stringf("Assigning write ports... (candidate configs: %zu)", cfgs.size()));
Copy link
Member

Choose a reason for hiding this comment

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

As I am reading into the standard std::vector<T>::size() returns an implementation-defined size type. Do we need to both use %zu and add an explicit cast to size_t for this to be portable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can implementation-defined size type be larger than architecture-defined size type? Does C++ standard require vector to be completely in memory? If yes, then cast to size_t is safe, if not... 64-bit size_type on 32-bit CPU with 32-bit size_t... Should be unlikely enough. Even current state is better, than the one before.

Copy link
Member

Choose a reason for hiding this comment

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

From a practical perspective, I would argue that if you have more than 4 billion possible configuration options to choose between to map your memory instance, getting the number truncated in a debug log message is the least of your problems... we could cast to uint64_t just in case, but I'm happy with anything as long as we don't cast to char.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will just cast to size_t

@uis246
Copy link
Contributor Author

uis246 commented Nov 29, 2023

Did I randomy request review?

@nakengelhardt
Copy link
Member

Nah, it's a github feature where it automatically requests review when any file listed in CODEOWNERS is modified. (Also, IIRC you need at least triage permissions on a repo to request reviews.)

@povik
Copy link
Member

povik commented Dec 11, 2023

@uis246 Can I force-push to your branch with the size_t casts so we can merge this?

@uis246
Copy link
Contributor Author

uis246 commented Dec 15, 2023

Yes. Sorry I forgot about this.

@povik povik merged commit 149bcd8 into YosysHQ:master Jan 15, 2024
16 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.

3 participants