git: 6e6aabe8bc2c - stable/13 - stand/ofw: Use strpbrk instead of two strchrs

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 22:13:05 UTC
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6e6aabe8bc2cd31c84e9be263afd9d003a27cca2

commit 6e6aabe8bc2cd31c84e9be263afd9d003a27cca2
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-11-29 20:02:40 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-01-24 21:49:37 +0000

    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
    
    (cherry picked from commit b60164c9f4d823b3e9fbcb733f92d181c704f415)
---
 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));
 }
 
 /*