-
Notifications
You must be signed in to change notification settings - Fork 0
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
printk adding unexpected padding '0' with ("%p") #1943
Comments
by Andrew Boie: I think this should be a P3, not a P2 |
by Sharron LIU: Checked two related docs. printf (libc) https://www.gnu.org/software/libc/manual/html_mono/libc.html#Other-Output-Conversions
printk (kernel) https://www.kernel.org/doc/Documentation/printk-formats.txt
Zephyr printk probably behaves similar to the linux kernel printk, with padding '0'. |
by Leandro Pereira: A pointer is always 4-bytes long in Zephyr, so it makes sense, to me, to always ignore the precision when printing it out with printk(). It seems that whoever wrote the printk() in Linux agrees with this as well. If you need to print a pointer that is known to have just two nibbles, convert it to an uintptr_t and use %x instead: printk() is supposed to be tiny, and adding cases that are rare as this will increase the code size for absolutely no need. |
Related to GH-1460 |
Reported by Sharron LIU:
printk("%-2p", (void *)42);
expected:
0x2a
actual
0x0000002a
printf behaves as expected.
Is there any reason for printk to add prefix '0' when specifying format "%p"?
(Imported from Jira ZEP-2102)
The text was updated successfully, but these errors were encountered: