[Crosstoolchain-logs] [device-tree-compiler] 255/357: dtc: Test and fix conversion to/from old dtb versions

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:06:19 UTC 2016


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

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

commit a266e5c1e105487795aa2e6fe0b52cfdb8a0a71d
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Thu Feb 28 20:55:37 2008 +1100

    dtc: Test and fix conversion to/from old dtb versions
    
    This patch adds testcases which test dtc when used to convert between
    different dtb versions.  These tests uncovered a couple of bugs
    handling old dtb versions, which are also fixed.
    
    Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 flattree.c         | 14 ++++++--------
 tests/run_tests.sh | 13 +++++++++++++
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/flattree.c b/flattree.c
index b6be786..6f43a89 100644
--- a/flattree.c
+++ b/flattree.c
@@ -410,7 +410,7 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version,
 	 * the reserve buffer, add the reserve map terminating zeroes,
 	 * the device tree itself, and finally the strings.
 	 */
-	blob = data_append_data(blob, &fdt, sizeof(fdt));
+	blob = data_append_data(blob, &fdt, vi->hdr_size);
 	blob = data_append_align(blob, 8);
 	blob = data_merge(blob, reservebuf);
 	blob = data_append_zeroes(blob, sizeof(struct fdt_reserve_entry));
@@ -809,7 +809,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
 
 struct boot_info *dt_from_blob(FILE *f)
 {
-	u32 magic, totalsize, version, size_str, size_dt;
+	u32 magic, totalsize, version, size_dt;
 	u32 off_dt, off_str, off_mem_rsvmap;
 	int rc;
 	char *blob;
@@ -889,11 +889,13 @@ struct boot_info *dt_from_blob(FILE *f)
 	if (off_str > totalsize)
 		die("String table offset exceeds total size\n");
 
-	size_str = -1;
 	if (version >= 3) {
-		size_str = be32_to_cpu(fdt->size_dt_strings);
+		u32 size_str = be32_to_cpu(fdt->size_dt_strings);
 		if (off_str+size_str > totalsize)
 			die("String table extends past total size\n");
+		inbuf_init(&strbuf, blob + off_str, blob + off_str + size_str);
+	} else {
+		inbuf_init(&strbuf, blob + off_str, blob + totalsize);
 	}
 
 	if (version >= 17) {
@@ -911,10 +913,6 @@ struct boot_info *dt_from_blob(FILE *f)
 	inbuf_init(&memresvbuf,
 		   blob + off_mem_rsvmap, blob + totalsize);
 	inbuf_init(&dtbuf, blob + off_dt, blob + totalsize);
-	if (size_str >= 0)
-		inbuf_init(&strbuf, blob + off_str, blob + off_str + size_str);
-	else
-		inbuf_init(&strbuf, blob + off_str, blob + totalsize);
 
 	reservelist = flat_read_mem_reserve(&memresvbuf);
 
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 443177f..492453d 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -172,6 +172,19 @@ dtc_tests () {
 	run_test dtbs_equal_ordered $tree odts_$tree.test.dtb
     done
 
+    # Check version conversions
+    for tree in test_tree1.dtb ; do
+	 for aver in 1 2 3 16 17; do
+	     atree="ov${aver}_$tree.test.dtb"
+	     run_test dtc.sh -I dtb -O dtb -V$aver -o $atree $tree
+	     for bver in 16 17; do
+		 btree="ov${bver}_$atree"
+		 run_test dtc.sh -I dtb -O dtb -V$bver -o $btree $atree
+		 run_test dtbs_equal_ordered $btree $tree
+	     done
+	 done
+    done
+
     # Check some checks
     run_test dtc-checkfails.sh duplicate_node_names -- -I dts -O dtb dup-nodename.dts
     run_test dtc-checkfails.sh duplicate_property_names -- -I dts -O dtb dup-propname.dts

-- 
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