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
ulp_riscv_print: Add convenience function that supports different widths (IDFGH-12124) #13180
Conversation
👋 Hello mickeyl, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
@@ -37,6 +37,7 @@ void ulp_riscv_print_str(const char *str); | |||
* @param Hex number to print | |||
*/ | |||
void ulp_riscv_print_hex(int h); | |||
void ulp_riscv_print_hex_with_number_of_digits(int h, int number_of_digits); |
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.
Could you also add a function description to explain the purpose and the arguments?
@@ -49,3 +49,24 @@ void ulp_riscv_print_hex(int h) | |||
h <<= 4; // move the 2nd leftmost byte to the left, to be extracted next | |||
} | |||
} | |||
|
|||
void ulp_riscv_print_hex_with_number_of_digits(int h, int number_of_digits) |
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.
Since the input here is int h
, the maximum number of hex digits would be 8. In this case, I assume the purpose of this function would be to print < 8 bytes. Is the understanding correct?
{ | ||
int x; | ||
int c; | ||
|
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.
Would be good to add a sanity check for number_of_digits < 0
and number_of_digits >= 8
. The first case should result in a error for the user and the second case should default the call to ulp_riscv_print_hex()
.
return; | ||
} | ||
|
||
// Does not print '0x', only the digits (8 digits to print) |
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.
// Does not print '0x', only the digits (8 digits to print) | |
// Does not print '0x', only the digits specified by the number_of_digits argument |
Thanks for the contribution @mickeyl! I've left some minor queries and comments. Once they are addressed, we should be good to merge. Thanks! |
@sudeep-mohanty Thanks for your comments. I have rebuild the pull request putting them into account. Please have another look. |
Hi @mickeyl, I do not see the updated changes. Maybe you missed committing them? 🤔 |
@sudeep-mohanty Indeed, my force-push didn't work for some reason. It should be visible now. |
Thanks @mickeyl. Changes LGTM. I shall do some more tests and then merge it. |
sha=89413eaab6501749f54072d80065c499b72c2c26 |
ULP's
print_hex
is pretty handy, but hardcoded touint32
with 8 digits. This patch adds a convenience function that supports different widths.