mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-14 00:37:41 -04:00
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>
This commit is contained in:
parent
cc392f0890
commit
fca296445e
2 changed files with 2 additions and 1 deletions
1
dtc.h
1
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))
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue