diff options
author | Sami Kerola | 2018-05-26 22:36:17 +0200 |
---|---|---|
committer | Sami Kerola | 2018-09-02 19:28:08 +0200 |
commit | d2b540022b8df6fe4aa339c6b35cf9f980a9e877 (patch) | |
tree | 7fb5a1ea97e7bc6bbdbc37397904b884ee2f6804 /text-utils | |
parent | more: remove 'register' keywords (diff) | |
download | kernel-qcow2-util-linux-d2b540022b8df6fe4aa339c6b35cf9f980a9e877.tar.gz kernel-qcow2-util-linux-d2b540022b8df6fe4aa339c6b35cf9f980a9e877.tar.xz kernel-qcow2-util-linux-d2b540022b8df6fe4aa339c6b35cf9f980a9e877.zip |
more: do not call fileno() for std{in,out,err} streams
These file descriptor numbers are well known, use them from unistd.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils')
-rw-r--r-- | text-utils/more.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/text-utils/more.c b/text-utils/more.c index 225ec2dbe..f7a443b2b 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -769,7 +769,7 @@ static int readch(struct more_control *ctl) unsigned char c; errno = 0; - if (read(fileno(stderr), &c, 1) <= 0) { + if (read(STDERR_FILENO, &c, 1) <= 0) { if (errno != EINTR) end_it(0); else @@ -1762,7 +1762,7 @@ static void chgwinsz(int dummy __attribute__((__unused__))) struct winsize win; signal(SIGWINCH, SIG_IGN); - if (ioctl(fileno(stdout), TIOCGWINSZ, &win) != -1) { + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1) { if (win.ws_row != 0) { global_ctl->Lpp = win.ws_row; global_ctl->nscroll = global_ctl->Lpp / 2 - 1; @@ -1794,7 +1794,7 @@ static void initterm(struct more_control *ctl) struct winsize win; #ifndef NON_INTERACTIVE_MORE - ctl->no_tty = tcgetattr(fileno(stdout), &ctl->otty); + ctl->no_tty = tcgetattr(STDOUT_FILENO, &ctl->otty); #endif if (!ctl->no_tty) { ctl->docrterase = (ctl->otty.c_cc[VERASE] != 255); @@ -1809,7 +1809,7 @@ static void initterm(struct more_control *ctl) ctl->ul_opt = 0; } else { #ifdef TIOCGWINSZ - if (ioctl(fileno(stdout), TIOCGWINSZ, &win) < 0) { + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) < 0) { #endif ctl->Lpp = tigetnum(TERM_LINES); ctl->Mcol = tigetnum(TERM_COLS); @@ -1886,8 +1886,8 @@ static void initterm(struct more_control *ctl) if ((ctl->shell = getenv("SHELL")) == NULL) ctl->shell = "/bin/sh"; } - ctl->no_intty = tcgetattr(fileno(stdin), &ctl->otty); - tcgetattr(fileno(stderr), &ctl->otty); + ctl->no_intty = tcgetattr(STDIN_FILENO, &ctl->otty); + tcgetattr(STDERR_FILENO, &ctl->otty); ctl->savetty0 = ctl->otty; ctl->hardtabs = (ctl->otty.c_oflag & TABDLY) != TAB3; if (!ctl->no_tty) { |