cam: Fix wiring fence post error

If the last matching device entry partially matched in camperiphunit,
but then hit a continue case, we'd mistakenly think we had a match on
that entry. This lead to a number of problems downstream (usually a
belief that we had a duplicate wiring hint because unit = 0 is the
default). Fix this by using a for loop that does the assignment before
the loop termination test.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D33873
This commit is contained in:
Warner Losh 2022-01-13 15:22:13 -07:00
parent 82bfeeff10
commit 272e4f5384

View file

@ -611,8 +611,9 @@ camperiphunit(struct periph_driver *p_drv, path_id_t pathid,
unit = 0;
i = 0;
dname = periph_name;
while (resource_find_dev(&i, dname, &dunit, NULL, NULL) == 0) {
wired = false;
for (wired = false; resource_find_dev(&i, dname, &dunit, NULL, NULL) == 0;
wired = false) {
if (resource_string_value(dname, dunit, "at", &strval) == 0) {
if (strcmp(strval, pathbuf) != 0)
continue;