lib/port.c: getttyuser(): Remove dead code

port.pt_names cannot be NULL; it always points to the static array ttys.

$ grep -rn pt_names
lib/port.c:157:	port.pt_names = ttys;
lib/port.c:159:		port.pt_names[j] = cp;
lib/port.c:172:	port.pt_names[j] = NULL;
lib/port.c:344:		for (i = 0; NULL != port->pt_names[i]; i++) {
lib/port.c:345:			if (portcmp (port->pt_names[i], tty) == 0) {
lib/port.c:350:		if (port->pt_names[i] == 0) {
lib/port.h:39: *	pt_names - pointer to array of device names in /dev/
lib/port.h:45:	char **pt_names;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: a4b91048e9b5 ("lib/port.c: getttyuser(): Remove dead code")
Link: <https://github.com/shadow-maint/shadow/pull/1037>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar 2024-07-02 14:03:27 +02:00
parent d63956d640
commit 5f4152e361
No known key found for this signature in database
GPG Key ID: 9E8C1AFBBEFFDB32

View File

@ -339,10 +339,8 @@ static struct port *getttyuser (const char *tty, const char *user)
setportent ();
while ((port = getportent ()) != NULL) {
if ( (0 == port->pt_names)
|| (0 == port->pt_users)) {
if (NULL == port->pt_users)
continue;
}
for (i = 0; NULL != port->pt_names[i]; i++) {
if (portcmp (port->pt_names[i], tty) == 0) {