]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ttyutils: improve get_terminal_default_type() code
authorKarel Zak <kzak@redhat.com>
Wed, 31 May 2023 07:18:06 +0000 (09:18 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 31 May 2023 07:18:06 +0000 (09:18 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/ttyutils.c

index 7c8860e63b97fe5a3d7a495d5aadee641a1adeb0..bacd7307727c38427362cacf72950b2f7a53462c 100644 (file)
@@ -163,17 +163,15 @@ int get_terminal_type(const char **type)
 
 char *get_terminal_default_type(const char *ttyname, int is_serial)
 {
-#ifdef HAVE_GETTTYNAM
        if (ttyname) {
+#ifdef HAVE_GETTTYNAM
                struct ttyent *ent = getttynam(ttyname);
 
                if (ent && ent->ty_type)
                        return strdup(ent->ty_type);
-       }
 #endif
 
 #if defined (__s390__) || defined (__s390x__)
-       if (ttyname) {
                /*
                 * Special terminal on first serial line on a S/390(x) which
                 * is due legacy reasons a block terminal of type 3270 or
@@ -186,8 +184,8 @@ char *get_terminal_default_type(const char *ttyname, int is_serial)
                        return strdup(DEFAULT_TTY32);
                else if (strcmp(ttyname, "ttyS1") == 0)         /* linux/drivers/s390/char/sclp_vt220.c */
                        return strdup(DEFAULT_TTYS1);
-       }
 #endif
+       }
 
        return strdup(is_serial ? DEFAULT_STERM : DEFAULT_VCTERM);
 }