From ae17e0291d313e08a2a3071083a8e2b5a4a362b2 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Mon, 15 Jan 2024 17:18:33 +0100 Subject: [PATCH] lib/port.c: getportent(): Call strpbrk(3) instead of open-coding it Signed-off-by: Alejandro Colomar --- lib/port.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/port.c b/lib/port.c index 8a45b67e..05b95651 100644 --- a/lib/port.c +++ b/lib/port.c @@ -127,7 +127,7 @@ static struct port *getportent (void) * - parse off a list of days and times */ - again: +again: /* * Get the next line and remove optional trailing '\n'. @@ -154,13 +154,9 @@ static struct port *getportent (void) port.pt_names = ttys; for (cp = buf, j = 0; j < PORT_TTY; j++) { port.pt_names[j] = cp; - while (('\0' != *cp) && (':' != *cp) && (',' != *cp)) { - cp++; - } - - if ('\0' == *cp) { + cp = strpbrk(cp, ":,"); + if (cp == NULL) goto again; /* line format error */ - } if (':' == *cp) { /* end of tty name list */ break;