lib/tty: fix get_terminal_name() usage, cleanup code

Signed-off-by: Karel Zak <kzak@redhat.com>