From b60164c9f4d823b3e9fbcb733f92d181c704f415 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 29 Nov 2022 13:02:40 -0700 Subject: [PATCH] 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 --- stand/libofw/devicename.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c index 11c0a1719ff3..353675db6b1f 100644 --- a/stand/libofw/devicename.c +++ b/stand/libofw/devicename.c @@ -43,27 +43,24 @@ static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **); int ofw_getdev(void **vdev, const char *devspec, const char **path) { - struct ofw_devdesc **dev = (struct ofw_devdesc **)vdev; - int rv; + struct ofw_devdesc **dev = (struct ofw_devdesc **)vdev; + int rv; - /* - * If it looks like this is just a path and no - * device, go with the current device. - */ - if ((devspec == NULL) || - ((strchr(devspec, '@') == NULL) && - (strchr(devspec, ':') == NULL))) { - - if (((rv = ofw_parsedev(dev, getenv("currdev"), NULL)) == 0) && - (path != NULL)) - *path = devspec; - return(rv); - } + /* + * If it looks like this is just a path and no device, go with the current + * device. + */ + if (devspec == NULL || strpbrk(devspec, ":@") == NULL) { + if (((rv = ofw_parsedev(dev, getenv("currdev"), NULL)) == 0) && + (path != NULL)) + *path = devspec; + return(rv); + } - /* - * Try to parse the device name off the beginning of the devspec - */ - return(ofw_parsedev(dev, devspec, path)); + /* + * Try to parse the device name off the beginning of the devspec + */ + return(ofw_parsedev(dev, devspec, path)); } /*