From 4e12b1a2a9e68685dff61acaee1e1f6c377d978c Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Tue, 23 Dec 2008 23:36:47 +0000 Subject: libbb: introduce and use xmalloc_ttyname (-32 in bss). ash: small code shrink text data bss dec hex filename 793669 504 7524 801697 c3ba1 busybox_old 793659 504 7492 801655 c3b77 busybox_unstripped --- loginutils/login.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'loginutils/login.c') diff --git a/loginutils/login.c b/loginutils/login.c index a18b4d5d7..af871436a 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -275,7 +275,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) if (!isatty(0) || !isatty(1) || !isatty(2)) return EXIT_FAILURE; /* Must be a terminal */ safe_strncpy(full_tty, "UNKNOWN", sizeof(full_tty)); - tmp = ttyname(0); + tmp = xmalloc_ttyname(STDIN_FILENO); if (tmp) { safe_strncpy(full_tty, tmp, sizeof(full_tty)); if (strncmp(full_tty, "/dev/", 5) == 0) @@ -285,12 +285,12 @@ int login_main(int argc UNUSED_PARAM, char **argv) read_or_build_utent(&utent, run_by_root); if (opt & LOGIN_OPT_h) { - USE_FEATURE_UTMP( + if (ENABLE_FEATURE_UTMP) safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host)); - ) fromhost = xasprintf(" on '%s' from '%s'", short_tty, opt_host); - } else + } else { fromhost = xasprintf(" on '%s'", short_tty); + } /* Was breaking "login " from shell command line: */ /*bb_setpgrp();*/ -- cgit v1.2.3