Add %X option to printf functions.
PATCH 1/1 Add %X option to printf functions.
From: Paulo Flabiano Smorigo <[email protected]>
---
grub-core/kern/misc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
grub-core/kern/misc.c +5 -2
@@ -588,7 +588,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)static inline char *grub_lltoa (char *str,int c,unsigned long long n) { -unsigned base = (c =='x' ) ?16 :10 ; +unsigned base = ((c =='x' ) || (c =='X' )) ?16 :10 ;char *p;if ((long long ) n <0 && c =='d' )
@@ -603,7 +603,7 @@ grub_lltoa (char *str, int c, unsigned long long n)do {unsigned d = (unsigned ) (n &0xf ); - *p++ = (d >9 ) ? d +'a' -10 : d +'0' ; + *p++ = (d >9 ) ? d + ((c =='x' ) ?'a' :'A' ) -10 : d +'0' ; }while (n >>=4 ); else
@@ -676,6 +676,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, {case 'p' :case 'x' : +case 'X' :case 'u' :case 'd' :case 'c' :
@@ -762,6 +763,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args,switch (c) {case 'x' : +case 'X' :case 'u' : args->ptr[curn].type =UNSIGNED_INT + longfmt;break ;
@@ -900,6 +902,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, c ='x' ;/* Fall through. */ case 'x' : +case 'X' :case 'u' :case 'd' : {
Signature · 1 line
2.21.0
Quoted 4 lines · Javier Martinez Canillas
From: Paulo Flabiano Smorigo <[email protected]>
Signed-off-by Paulo Flabiano Smorigo <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>
May I ask you to add an explanation to the commit message why?
If you do that you can add "Reviewed-by: Daniel Kiper <[email protected]>".
Daniel
Hello Daniel,
Thanks for the quick feedback.
Quoted 9 lines · Daniel Kiper
Quoted 4 lines · Javier Martinez Canillas
From: Paulo Flabiano Smorigo <[email protected]>
Signed-off-by Paulo Flabiano Smorigo <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>May I ask you to add an explanation to the commit message why?
If you do that you can add "Reviewed-by: Daniel Kiper <[email protected]>".
The reason why we had this patch is that a following patch was using this %X format specifier to print IP addresses as uppercase hexadecimal.
But as Vladimir suggested, we could just use %x and grub_toupper(). So If adding an %X format specifier seems unnecessary and would only make grub core bigger, then I'll just change the other patch and drop this one.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat
Quoted 11 lines · Javier Martinez Canillas
Hello Daniel,
Thanks for the quick feedback.
Quoted 6 lines · Daniel Kiper
Quoted 4 lines · Javier Martinez Canillas
From: Paulo Flabiano Smorigo <[email protected]>
Signed-off-by Paulo Flabiano Smorigo <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>
Quoted 6 lines
Quoted 3 lines
May I ask you to add an explanation to the commit message why?
If you do that you can add "Reviewed-by: Daniel Kiper <[email protected]>".The reason why we had this patch is that a following patch was using this %X format specifier to print IP addresses as uppercase hexadecimal.
OK but then I would like to see patch using "%X" immediately following this one. So, both have to be posted together.
And please add similar explanation as you did above to the commit message.
Quoted 3 lines
But as Vladimir suggested, we could just use %x and
grub_toupper(). So If adding an %X format specifier seems unnecessary and would only make grub core bigger, then I'll just change the other patch and drop this one.
TBH I prefer to have grub_printf() behavior similar to regular printf(). And I do not think that this change will increase core image size much.
Daniel
Quoted 16 lines · Daniel Kiper
Quoted 15 lines · Javier Martinez Canillas
Hello Daniel,
Thanks for the quick feedback.
Quoted 9 lines · Daniel Kiper
Quoted 4 lines · Javier Martinez Canillas
From: Paulo Flabiano Smorigo <[email protected]>
Signed-off-by Paulo Flabiano Smorigo <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>May I ask you to add an explanation to the commit message why?
If you do that you can add "Reviewed-by: Daniel Kiper <[email protected]>".
Quoted 7 lines
Quoted 2 lines
The reason why we had this patch is that a following patch was using this %X format specifier to print IP addresses as uppercase hexadecimal.
OK but then I would like to see patch using "%X" immediately following this one. So, both have to be posted together.
And please add similar explanation as you did above to the commit message.
Ok, I'll re-post with a better commit message as a series when posting the other patch that's using the %X specifier then.
Quoted 8 lines
Quoted 4 lines
But as Vladimir suggested, we could just use %x and
grub_toupper(). So If adding an %X format specifier seems unnecessary and would only make grub core bigger, then I'll just change the other patch and drop this one.TBH I prefer to have
grub_printf()behavior similar to regularprintf(). And I do not think that this change will increase core image size much.
Yes, agreed.
Quoted 2 lines
Daniel
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat