aboutsummaryrefslogtreecommitdiff
path: root/checks.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2017-10-29 22:54:09 +0100
committerDavid Gibson <david@gibson.dropbear.id.au>2017-11-11 19:36:42 +1100
commit7975f6422260af4ac7ae2fcdff0ef2a6e391ab71 (patch)
treeb8ea452fcf138b59d6ccb897e582e44e2cd371a0 /checks.c
parentfca296445eabf3cfe986e89dd8711c0be583036d (diff)
downloaddtc-7975f6422260af4ac7ae2fcdff0ef2a6e391ab71.zip
dtc-7975f6422260af4ac7ae2fcdff0ef2a6e391ab71.tar.gz
dtc-7975f6422260af4ac7ae2fcdff0ef2a6e391ab71.tar.bz2
Fix widespread incorrect use of strneq(), replace with new strprefixeq()
Every remaining usage of strneq() is, in fact, incorrect. They're trying to check that the first n characters of one string exactly match another string. But, they fall into the classic trap of strncmp() on which strneq() is based. If n is less than the length of the second string, they only check that the first string matches the start of the second, not the whole of it. To fix this, remove strneq() and replace it with a strprefixeq() function which does what we want here. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'checks.c')
-rw-r--r--checks.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/checks.c b/checks.c
index 770af32..f5bf5f9 100644
--- a/checks.c
+++ b/checks.c
@@ -696,8 +696,8 @@ static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *
node->bus = &pci_bus;
- if (!strneq(node->name, "pci", node->basenamelen) &&
- !strneq(node->name, "pcie", node->basenamelen))
+ if (!strprefixeq(node->name, node->basenamelen, "pci") &&
+ !strprefixeq(node->name, node->basenamelen, "pcie"))
FAIL(c, dti, "Node %s node name is not \"pci\" or \"pcie\"",
node->fullpath);
@@ -828,7 +828,7 @@ static bool node_is_compatible(struct node *node, const char *compat)
for (str = prop->val.val, end = str + prop->val.len; str < end;
str += strnlen(str, end - str) + 1) {
- if (strneq(str, compat, end - str))
+ if (strprefixeq(str, end - str, compat))
return true;
}
return false;