[Crosstoolchain-logs] [device-tree-compiler] 12/29: Add strstarts() helper function
Vagrant Cascadian
vagrant at moszumanska.debian.org
Tue Jan 23 06:34:38 UTC 2018
This is an automated email from the git hooks/post-receive script.
vagrant pushed a commit to branch debian/master
in repository device-tree-compiler.
commit fca296445eabf3cfe986e89dd8711c0be583036d
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Sun Oct 29 18:56:03 2017 +0100
Add strstarts() helper function
nodename_from_path() in flattree.c uses strneq() to test that one
string starts with another. This is, in fact, the only correct usage
of strneq() in the entire tree. To make things harder to confuse, add
a strstarts() function for this purpose.
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
dtc.h | 1 +
flattree.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dtc.h b/dtc.h
index 760f9e3..bb0b91b 100644
--- a/dtc.h
+++ b/dtc.h
@@ -68,6 +68,7 @@ typedef uint32_t cell_t;
#define streq(a, b) (strcmp((a), (b)) == 0)
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
+#define strstarts(s, prefix) (strncmp((s), (prefix), strlen(prefix)) == 0)
#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
diff --git a/flattree.c b/flattree.c
index fcf7154..8d268fb 100644
--- a/flattree.c
+++ b/flattree.c
@@ -731,7 +731,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath)
plen = strlen(ppath);
- if (!strneq(ppath, cpath, plen))
+ if (!strstarts(cpath, ppath))
die("Path \"%s\" is not valid as a child of \"%s\"\n",
cpath, ppath);
--
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