summaryrefslogtreecommitdiff
path: root/flattree.c
diff options
context:
space:
mode:
author David Gibson <david@gibson.dropbear.id.au> 2017-10-29 18:56:03 +0100
committer David Gibson <david@gibson.dropbear.id.au> 2017-11-11 19:36:14 +1100
commitfca296445eabf3cfe986e89dd8711c0be583036d (patch)
tree568b6a37bcfed0bf80d11613a17f16605ee9bfe7 /flattree.c
parentcc392f089007873734ae2fbfb384df7acb4fe3c6 (diff)
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@gibson.dropbear.id.au>
Diffstat (limited to 'flattree.c')
-rw-r--r--flattree.c2
1 files changed, 1 insertions, 1 deletions
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);