summaryrefslogtreecommitdiff
path: root/flattree.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2008-02-27 13:45:13 +1100
committerJon Loeliger <jdl@loeliger.com>2008-03-23 08:00:32 -0500
commitfa5b520ccb5e8da8d67ebc1926416753684f4e70 (patch)
tree2fcb2d1c043c5c374279ea02bf63f9040daa254b /flattree.c
parent7c635dcb2f43529bbe7903f5a6ce56984d21b964 (diff)
downloaddtc-fa5b520ccb5e8da8d67ebc1926416753684f4e70.tar.gz
dtc: Implement checks for the format of node and property names
This patch adds checks to the checking framework to verify that node and property names contain only legal characters, and in the case of node names there is at most one '@'. At present when coming from dts input, this is mostly already ensured by the grammer, however putting the check later means its easier to generate helpful error messages rather than just "syntax error". For dtb input, these checks replace the older similar check built into flattree.c. Testcases for the checks are also implemented. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'flattree.c')
-rw-r--r--flattree.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/flattree.c b/flattree.c
index 7b6d7fe..b6be786 100644
--- a/flattree.c
+++ b/flattree.c
@@ -729,29 +729,14 @@ static char *nodename_from_path(const char *ppath, const char *cpath)
return strdup(lslash+1);
}
-static const char PROPCHAR[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,._+*#?-";
-static const char UNITCHAR[] = "0123456789abcdef,";
-
-static int check_node_name(const char *name)
+static int find_basenamelen(const char *name)
{
- const char *atpos;
- int basenamelen;
-
- atpos = strrchr(name, '@');
+ const char *atpos = strchr(name, '@');
if (atpos)
- basenamelen = atpos - name;
+ return atpos - name;
else
- basenamelen = strlen(name);
-
- if (strspn(name, PROPCHAR) < basenamelen)
- return -1;
-
- if (atpos
- && ((basenamelen + 1 + strspn(atpos+1, UNITCHAR)) < strlen(name)))
- return -1;
-
- return basenamelen;
+ return strlen(name);
}
static struct node *unflatten_tree(struct inbuf *dtbuf,
@@ -775,10 +760,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
node->fullpath = join_path(parent_path, node->name);
}
- node->basenamelen = check_node_name(node->name);
- if (node->basenamelen < 0) {
- fprintf(stderr, "Warning \"%s\" has incorrect format\n", node->name);
- }
+ node->basenamelen = find_basenamelen(node->name);
do {
struct property *prop;