fdtdump: fix output of bytestring properties
PATCH 1/1 fdtdump: fix output of bytestring properties
Currently, when fdtdump prints bytestring property, it prints ffffff in front of bytes with first bit equal to 1 (0x80 - 0xff)
For example:
property = [80];
will become
property = [ffffff80];
This patch fixes it.
--- util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util.c 2015-07-08 16:45:53.095127906 +0300 renamed from util.c.orig 2015-07-08 16:45:49.374127737 +0300 +1 -1
@@ -378,7 +378,7 @@ void utilfdt_print_data(const char *data } else { printf(" = ["); for (i = 0; i < len; i++) - printf("%02x%s", *p++, i < len - 1 ? " " : ""); + printf("%02hhx%s", *p++, i < len - 1 ? " " : ""); printf("]"); } }
Quoted 8 lines · Prusov Igor Vladimirovich
Currently, when fdtdump prints bytestring property, it prints ffffff in front of bytes with first bit equal to 1 (
0x80-0xff)For example:
property = [80];
will become
property = [ffffff80];
This patch fixes it.
Actually, it's worse than that. It will print incorrectly on platforms where char is signed by default, but not on those where it is unsigned by default.
Quoted 4 lines
Signed-off-by Igor Prusov <[email protected]>--- util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks for this, but there are a couple of problems with this patch that make it difficult for me to apply directly.
First, the usual convention is to diff the whole tree, not individual files, so the resulting patch can be applied with -p1.
Second, it looks like your mailer has mangled the patch, replacing tabs with spaces, which means it won't apply directly.
Please check those if you send patches in future.
FOr this specific bug, I'd actually prefer a slightly different fix, so I've gone ahead and applied my own slightly different fix.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson