From bf84b3a8555da056962128db1c0adcba35953e53 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 2 Jul 2024 15:49:48 +0200 Subject: [PATCH] lib/port.c: getttyuser(): Use goto to break out of nested loops Signed-off-by: Alejandro Colomar --- lib/port.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/port.c b/lib/port.c index 14ab06c96..04dc5c1c2 100644 --- a/lib/port.c +++ b/lib/port.c @@ -353,15 +353,13 @@ static struct port *getttyuser (const char *tty, const char *user) for (j = 0; NULL != port->pt_users[j]; j++) { if ( (strcmp (user, port->pt_users[j]) == 0) - || (strcmp (port->pt_users[j], "*") == 0)) { - break; + || (strcmp (port->pt_users[j], "*") == 0)) + { + goto end; } } - - if (port->pt_users[j] != 0) { - break; - } } +end: endportent (); return port; } -- 2.47.3