stand/ofw: Use strpbrk instead of two strchrs

No need to call strchr twice, when one call to strpbrk will do the
job.. Test booted with qemu-powerpc + mac99 successfully.
Minor style(9) tweaks as well.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-11-29 13:02:40 -07:00
parent bc9a5b0497
commit b60164c9f4

View File

@ -43,27 +43,24 @@ static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **);
int int
ofw_getdev(void **vdev, const char *devspec, const char **path) ofw_getdev(void **vdev, const char *devspec, const char **path)
{ {
struct ofw_devdesc **dev = (struct ofw_devdesc **)vdev; struct ofw_devdesc **dev = (struct ofw_devdesc **)vdev;
int rv; int rv;
/* /*
* If it looks like this is just a path and no * If it looks like this is just a path and no device, go with the current
* device, go with the current device. * device.
*/ */
if ((devspec == NULL) || if (devspec == NULL || strpbrk(devspec, ":@") == NULL) {
((strchr(devspec, '@') == NULL) && if (((rv = ofw_parsedev(dev, getenv("currdev"), NULL)) == 0) &&
(strchr(devspec, ':') == NULL))) { (path != NULL))
*path = devspec;
if (((rv = ofw_parsedev(dev, getenv("currdev"), NULL)) == 0) && return(rv);
(path != NULL)) }
*path = devspec;
return(rv);
}
/* /*
* Try to parse the device name off the beginning of the devspec * Try to parse the device name off the beginning of the devspec
*/ */
return(ofw_parsedev(dev, devspec, path)); return(ofw_parsedev(dev, devspec, path));
} }
/* /*