[Crosstoolchain-logs] [device-tree-compiler] 159/198: fdtdump: Fix bug printing bytestrings with negative values

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:07:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

zumbi pushed a commit to branch upstream/1.4.x
in repository device-tree-compiler.

commit e5e6df7c37f7de13af33a3096e9c66127bb75d15
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Thu Jul 9 13:47:19 2015 +1000

    fdtdump: Fix bug printing bytestrings with negative values
    
    On systems where 'char' is signed, fdtdump will currently print the wrong
    thing on properties containing bytestring values with "negative" bytes
    (that is with values from 0x80..0xff).  The fdtdump testcase is extended
    to cover this case too.
    
    This corrects the problem by forcing use of unsigned char - although this
    is perhaps another indication that fdtdump is a buggy hack and if you want
    to do real work you should use dtc -O dts.
    
    Reported-by: Igor Prusov <Igor.V.Prusov at mcst.ru>
    Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 tests/fdtdump.dts | 1 +
 util.c            | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/fdtdump.dts b/tests/fdtdump.dts
index b9d917b..b83b7df 100644
--- a/tests/fdtdump.dts
+++ b/tests/fdtdump.dts
@@ -23,6 +23,7 @@
 	randomnode {
 		string =  "foo", "stuff";
 		bytes = [61 62 63 64 65];
+		nbytes = [80 ff];
 		child {
 		};
 	};
diff --git a/util.c b/util.c
index 9d65226..cbb945b 100644
--- a/util.c
+++ b/util.c
@@ -349,7 +349,6 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size)
 void utilfdt_print_data(const char *data, int len)
 {
 	int i;
-	const char *p = data;
 	const char *s;
 
 	/* no data, don't print */
@@ -376,6 +375,7 @@ void utilfdt_print_data(const char *data, int len)
 			       i < (len - 1) ? " " : "");
 		printf(">");
 	} else {
+		const unsigned char *p = (const unsigned char *)data;
 		printf(" = [");
 		for (i = 0; i < len; i++)
 			printf("%02x%s", *p++, i < len - 1 ? " " : "");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list