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