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

Fixed printf format to print 0 correctly #1333

Merged
merged 1 commit into from
Sep 16, 2023

Conversation

fliiiix
Copy link
Contributor

@fliiiix fliiiix commented Sep 4, 2023

Otherwise 0 is printed as 0.

 // works
 printf("Command 0x%02x \n", 0x0);
 
 // broken for 0
 printf("Command %#02x \n", 0x0);
 printf("Command %#02x \n", 0x00);
 printf("Command %#02x \n", 0xFF);

https://godbolt.org/z/roGYqde3a

Copy link
Collaborator

@gszy gszy left a comment

Choose a reason for hiding this comment

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

I’d reword the commit message to something less about fixing correctness and more about improving consistency; both 0 and 0x00 are correct. Perhaps something like "Prefix all CDB bytes with 0x, including zeros".

@fliiiix
Copy link
Contributor Author

fliiiix commented Sep 4, 2023

fair enough updated

@Nightwalker-87 Nightwalker-87 merged commit 40fbdb4 into stlink-org:develop Sep 16, 2023
10 checks passed
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Sep 16, 2023
@Nightwalker-87 Nightwalker-87 changed the title Fix printf format to print 0 correctly Fixed printf format to print 0 correctly Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants