diff options
author | 2016-01-13 23:11:22 +0000 | |
---|---|---|
committer | 2016-01-13 23:11:22 +0000 | |
commit | 38a28d416b450c1ed6f6ac966996ecd1e51b3f88 (patch) | |
tree | a84f0a240fb0c010445d5e75fe5c14442d53e807 | |
parent | eliminate fallback from untrusted X11 forwarding to trusted (diff) | |
download | wireguard-openbsd-38a28d416b450c1ed6f6ac966996ecd1e51b3f88.tar.xz wireguard-openbsd-38a28d416b450c1ed6f6ac966996ecd1e51b3f88.zip |
Change aml_find_node() such that it only walks down the tree and doesn't
traverse sideways. This seems to be what all callersexpect it to do, and
fixes a bug in dwiic(4) where it would try to access i2c devices on busses
they're not attached to.
If there is any fallout from this change, the right thing to do is probably
to make sure callers pass the right node.
While there, change the return type to void, as the return value was useless
and none of the callers looked at it.
ok mlarkin@
-rw-r--r-- | sys/dev/acpi/dsdt.c | 24 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.h | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index 85885949141..769f8686096 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.218 2015/08/20 20:50:10 kettenis Exp $ */ +/* $OpenBSD: dsdt.c,v 1.219 2016/01/13 23:11:22 kettenis Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> * @@ -1249,26 +1249,26 @@ aml_walknodes(struct aml_node *node, int mode, nodecb(node, arg); } -int +void aml_find_node(struct aml_node *node, const char *name, int (*cbproc)(struct aml_node *, void *arg), void *arg) { + struct aml_node *child; const char *nn; - int st = 0; - while (node) { - if ((nn = node->name) != NULL) { + SIMPLEQ_FOREACH(child, &node->son, sib) { + nn = child->name; + if ((nn = child->name) != NULL) { if (*nn == AMLOP_ROOTCHAR) nn++; while (*nn == AMLOP_PARENTPREFIX) nn++; - if (!strcmp(name, nn)) - st = cbproc(node, arg); + if (strcmp(name, nn) == 0) { + /* Only recurse if cbproc() wants us to */ + if (cbproc(child, arg) == 0) + continue; + } } - /* Only recurse if cbproc() wants us to */ - if (!st) - aml_find_node(SIMPLEQ_FIRST(&node->son), name, cbproc, arg); - node = SIMPLEQ_NEXT(node, sib); + aml_find_node(child, name, cbproc, arg); } - return st; } /* diff --git a/sys/dev/acpi/dsdt.h b/sys/dev/acpi/dsdt.h index 8f04ef2ad23..bcecbae824e 100644 --- a/sys/dev/acpi/dsdt.h +++ b/sys/dev/acpi/dsdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.h,v 1.66 2016/01/13 10:11:43 kettenis Exp $ */ +/* $OpenBSD: dsdt.h,v 1.67 2016/01/13 23:11:22 kettenis Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -53,7 +53,7 @@ void aml_showvalue(struct aml_value *, int); void aml_walkroot(void); void aml_walktree(struct aml_node *); -int aml_find_node(struct aml_node *, const char *, +void aml_find_node(struct aml_node *, const char *, int (*)(struct aml_node *, void *), void *); int acpi_parse_aml(struct acpi_softc *, u_int8_t *, u_int32_t); |