diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-05 13:20:58 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-05 13:20:58 +0000 |
commit | 202ac504e1addf0aa2debd53e7cd2411cc73ac8c (patch) | |
tree | 20a02054110c8b0dbec1f94252a9d2b759dac3ae /loginutils | |
parent | 905ed8730f1b78461cf83e719a1e077214c2432c (diff) | |
download | busybox-202ac504e1addf0aa2debd53e7cd2411cc73ac8c.tar.gz |
*: code shrink by adding a wrapper around very common tcsetattr(0, TCSANOW, xx) op
function old new delta
tcsetattr_stdin_TCSANOW - 14 +14
set_sane_term 116 113 -3
top_main 1277 1273 -4
make_new_session 421 415 -6
rawmode 133 126 -7
reset_term 18 10 -8
die 43 35 -8
cookmode 62 54 -8
vlock_main 425 415 -10
read_line_input 3165 3155 -10
bb_askpass 357 347 -10
fsck_minix_main 3079 3065 -14
getty_main 2375 2332 -43
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/12 up/down: 14/-131) Total: -117 bytes
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/getty.c | 16 | ||||
-rw-r--r-- | loginutils/vlock.c | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c index 8b0e729fb..0f536888b 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -279,7 +279,7 @@ static void termios_init(struct termios *tp, int speed, struct options *op) */ #ifdef __linux__ /* flush input and output queues, important for modems! */ - ioctl(0, TCFLSH, TCIOFLUSH); + ioctl(0, TCFLSH, TCIOFLUSH); /* tcflush(0, TCIOFLUSH)? - same */ #endif tp->c_cflag = CS8 | HUPCL | CREAD | speed; @@ -297,7 +297,7 @@ static void termios_init(struct termios *tp, int speed, struct options *op) tp->c_cflag |= CRTSCTS; #endif - ioctl(0, TCSETS, tp); + tcsetattr_stdin_TCSANOW(tp); debug("term_io 2\n"); } @@ -334,7 +334,7 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) tp->c_iflag |= ISTRIP; /* enable 8th-bit stripping */ vmin = tp->c_cc[VMIN]; tp->c_cc[VMIN] = 0; /* don't block if queue empty */ - ioctl(0, TCSETS, tp); + tcsetattr_stdin_TCSANOW(tp); /* * Wait for a while, then read everything the modem has said so far and @@ -359,7 +359,7 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) /* Restore terminal settings. Errors will be dealt with later on. */ tp->c_iflag = iflag; tp->c_cc[VMIN] = vmin; - ioctl(0, TCSETS, tp); + tcsetattr_stdin_TCSANOW(tp); } /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */ @@ -404,7 +404,7 @@ static char *get_logname(char *logname, unsigned size_logname, /* Flush pending input (esp. after parsing or switching the baud rate). */ sleep(1); - ioctl(0, TCFLSH, TCIFLUSH); + ioctl(0, TCFLSH, TCIFLUSH); /* tcflush(0, TCIOFLUSH)? - same */ /* Prompt for and read a login name. */ logname[0] = '\0'; @@ -552,12 +552,13 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat } #endif /* Optionally enable hardware flow control */ -#ifdef CRTSCTS +#ifdef CRTSCTS if (op->flags & F_RTSCTS) tp->c_cflag |= CRTSCTS; #endif /* Finally, make the new settings effective */ + /* It's tcsetattr_stdin_TCSANOW() + error check */ ioctl_or_perror_and_die(0, TCSETS, tp, "%s: TCSETS", op->tty); } @@ -689,6 +690,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) * by patching the SunOS kernel variable "zsadtrlow" to a larger value; * 5 seconds seems to be a good value. */ + /* tcgetattr() + error check */ ioctl_or_perror_and_die(0, TCGETS, &termios, "%s: TCGETS", options.tty); #ifdef __linux__ @@ -753,7 +755,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) baud_index = (baud_index + 1) % options.numspeed; termios.c_cflag &= ~CBAUD; termios.c_cflag |= options.speeds[baud_index]; - ioctl(0, TCSETS, &termios); + tcsetattr_stdin_TCSANOW(&termios); } } diff --git a/loginutils/vlock.c b/loginutils/vlock.c index 42ef44732..0262da5bd 100644 --- a/loginutils/vlock.c +++ b/loginutils/vlock.c @@ -87,7 +87,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv) term.c_iflag |= IGNBRK; term.c_lflag &= ~ISIG; term.c_lflag &= ~(ECHO | ECHOCTL); - tcsetattr(STDIN_FILENO, TCSANOW, &term); + tcsetattr_stdin_TCSANOW(&term); do { printf("Virtual console%s locked by %s.\n", @@ -101,6 +101,6 @@ int vlock_main(int argc UNUSED_PARAM, char **argv) } while (1); ioctl(STDIN_FILENO, VT_SETMODE, &ovtm); - tcsetattr(STDIN_FILENO, TCSANOW, &oterm); + tcsetattr_stdin_TCSANOW(&oterm); fflush_stdout_and_exit(EXIT_SUCCESS); } |