[Crosstoolchain-logs] [device-tree-compiler] 210/357: dtc: Convert "name" property checking to new infrastructure

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:06:14 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 459c955cca6adfa393b9279ee595c60e199dbffe
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Wed Dec 5 09:40:23 2007 +1100

    dtc: Convert "name" property checking to new infrastructure
    
    This patch removes the old-style checking code for the "name" property
    - i.e. verifying that the "name" property, if present, matches the
    node name.  It replaces it with a pair of more-or-less equivalent
    checks in the new checking framework.
    
    This also promotes this check to a "structural" check, or at least an
    error-rather-than-warning test, since the structural/semantic
    distinction doesn't really apply in the new framework.
    
    A testcase for the check is also added.
    
    Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 checks.c                    | 54 ++++++++++++++++++++++++++++++++-------------
 tests/bad-name-property.dts |  7 ++++++
 tests/run_tests.sh          |  1 +
 3 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/checks.c b/checks.c
index fea89df..22f1b2a 100644
--- a/checks.c
+++ b/checks.c
@@ -170,6 +170,27 @@ out:
 }
 
 /*
+ * Utility check functions
+ */
+
+static void check_is_string(struct check *c, struct node *root,
+			    struct node *node)
+{
+	struct property *prop;
+	char *propname = c->data;
+
+	prop = get_property(node, propname);
+	if (!prop)
+		return; /* Not present, assumed ok */
+
+	if (!data_is_one_string(prop->val))
+		FAIL(c, "\"%s\" property in %s is not a string",
+		     propname, node->fullpath);
+}
+#define CHECK_IS_STRING(nm, propname, lvl) \
+	CHECK(nm, NULL, check_is_string, NULL, (propname), (lvl))
+
+/*
  * Structural check functions
  */
 
@@ -236,6 +257,23 @@ static void check_explicit_phandles(struct check *c, struct node *root,
 }
 NODE_CHECK(explicit_phandles, NULL, ERROR);
 
+static void check_name_properties(struct check *c, struct node *root,
+				  struct node *node)
+{
+	struct property *prop;
+
+	prop = get_property(node, "name");
+	if (!prop)
+		return; /* No name property, that's fine */
+
+	if ((prop->val.len != node->basenamelen+1)
+	    || (memcmp(prop->val.val, node->name, node->basenamelen) != 0))
+		FAIL(c, "\"name\" property in %s is incorrect (\"%s\" instead"
+		     " of base node name)", node->fullpath, prop->val.val);
+}
+CHECK_IS_STRING(name_is_string, "name", ERROR);
+NODE_CHECK(name_properties, NULL, ERROR, &name_is_string);
+
 /*
  * Reference fixup functions
  */
@@ -266,6 +304,7 @@ CHECK(phandle_references, NULL, NULL, fixup_phandle_references, NULL, ERROR,
 
 static struct check *check_table[] = {
 	&duplicate_node_names, &duplicate_property_names,
+	&name_is_string, &name_properties,
 	&explicit_phandles,
 	&phandle_references,
 };
@@ -350,25 +389,10 @@ static int must_be_string(struct property *prop, struct node *node)
 	return 1;
 }
 
-static int name_prop_check(struct property *prop, struct node *node)
-{
-	if ((prop->val.len != node->basenamelen+1)
-	    || !strneq(prop->val.val, node->name, node->basenamelen)) {
-		ERRMSG("name property \"%s\" does not match node basename in %s\n",
-		       prop->val.val,
-		       node->fullpath);
-		return 0;
-	}
-
-	return 1;
-}
-
 static struct {
 	char *propname;
 	int (*check_fn)(struct property *prop, struct node *node);
 } prop_checker_table[] = {
-	{"name", must_be_string},
-	{"name", name_prop_check},
 	{"linux,phandle", must_be_one_cell},
 	{"#address-cells", must_be_one_cell},
 	{"#size-cells", must_be_one_cell},
diff --git a/tests/bad-name-property.dts b/tests/bad-name-property.dts
new file mode 100644
index 0000000..4fde4be
--- /dev/null
+++ b/tests/bad-name-property.dts
@@ -0,0 +1,7 @@
+/dts-v1/;
+
+/ {
+	node at 0 {
+		name = "badthing";
+	};
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index d8bedca..9d32337 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -162,6 +162,7 @@ dtc_tests () {
     run_test dtc-checkfails.sh -I dts -O dtb minusone-phandle.dts
     run_test dtc-checkfails.sh -I dts -O dtb nonexist-node-ref.dts
     run_test dtc-checkfails.sh -I dts -O dtb nonexist-label-ref.dts
+    run_test dtc-checkfails.sh -I dts -O dtb bad-name-property.dts
 }
 
 while getopts "vt:m" ARG ; do

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