-
Notifications
You must be signed in to change notification settings - Fork 2k
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
print: Added size_t print format specifier #20194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, this looks good to me. I have a number of nitpicks inline, though.
Thanks for the detailed review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look through everything and only found a few minor things/nitpicks.
Should I squash the fixups and improve the commit messages a bit, or should I wait for more reviews? |
Feel free to squash |
- Added `PRIuSIZE`, `PRIxSIZE`, etc. to `architecure.h` - Changed `CODING_CONVENTIONS.md` regarding `size_t` printing Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
- Added helper function to avoid 'format-truncation' warning - Changed all `size_t` types to `unsigned` - Changed function names from `_FIB_` to `_fib_`
cdb9ba9
to
475a551
Compare
I squashed the fixups as well as the one review commit, and changed the commit messages a bit. |
Contribution description
As discussed in #20182, this PR adds custom print format specifiers for
size_t
(e.g.,PRIuSIZE
) that doesn't assumesizeof(unsigned) == sizeof(size_t)
toarchitecture.h
and changes thesize_t
printing recommendation inCODING_CONVENTIONS.md
Furthermore, the bulk of this PR consists of changes that modify print statements with
size_t
arguments to use the new print format specifiers.@maribu mentioned a possible switch to picolib in the near future. This would provide support for the currently problematic
%z
format specifier. If this is the preferred solution, I can easily replace thePRIuSIZE
,PRIxSIZE
, etc. macros with the corresponding%z
modifiers and remove the custom print format specifiers.Testing procedure
This shouldn't change any test or application.
To test the debug statement, set the appropriate
ENABLE_DEBUG
macro (or enable it globally).Issues/PRs references
See also #20182, #20154