]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/port.c: getttyuser(): Use goto to break out of nested loops
authorAlejandro Colomar <alx@kernel.org>
Tue, 2 Jul 2024 13:49:48 +0000 (15:49 +0200)
committerAlejandro Colomar <alx@kernel.org>
Sun, 14 Jul 2024 22:54:42 +0000 (00:54 +0200)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: bf84b3a8555d ("lib/port.c: getttyuser(): Use goto to break out of nested loops")
Link: <https://github.com/shadow-maint/shadow/pull/1037>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/port.c

index 4da49d681b2fca4785231189d4e8c052cb08bb0a..5f49984f6179520ca2c7bca4978a047de4a8186d 100644 (file)
@@ -354,15 +354,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;
 }