From 1aa7b0eba47e9452ea6454af501b33b70e05d060 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 13 Apr 2005 02:33:10 +0000 Subject: use STD{IN,OUT,ERR}_FILENO --- bin/ksh/edit.c | 4 ++-- games/hangman/getguess.c | 6 +++--- games/tetris/input.c | 6 +++--- libexec/lockspool/lockspool.c | 6 +++--- libexec/uucpd/uucpd.c | 6 +++--- sbin/scsi/scsi.c | 19 ++++++++----------- usr.bin/make/job.c | 4 ++-- usr.bin/mg/ttyio.c | 4 ++-- usr.bin/oldrdist/server.c | 10 +++++----- usr.bin/talk/io.c | 6 +++--- usr.bin/top/display.c | 4 ++-- usr.bin/top/top.c | 8 ++++---- usr.bin/window/wwrint.c | 6 +++--- usr.sbin/popa3d/protocol.c | 4 ++-- 14 files changed, 45 insertions(+), 48 deletions(-) diff --git a/bin/ksh/edit.c b/bin/ksh/edit.c index 6618e079a83..c4bac67a77d 100644 --- a/bin/ksh/edit.c +++ b/bin/ksh/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.28 2005/03/30 17:16:37 deraadt Exp $ */ +/* $OpenBSD: edit.c,v 1.29 2005/04/13 02:33:08 deraadt Exp $ */ /* * Command line editing - common code @@ -119,7 +119,7 @@ x_getc(void) char c; int n; - while ((n = blocking_read(0, &c, 1)) < 0 && errno == EINTR) + while ((n = blocking_read(STDIN_FILENO, &c, 1)) < 0 && errno == EINTR) if (trap) { x_mode(false); runtraps(0); diff --git a/games/hangman/getguess.c b/games/hangman/getguess.c index 047a8e2b264..c37970a8737 100644 --- a/games/hangman/getguess.c +++ b/games/hangman/getguess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getguess.c,v 1.6 2004/11/29 08:52:28 jsg Exp $ */ +/* $OpenBSD: getguess.c,v 1.7 2005/04/13 02:33:07 deraadt Exp $ */ /* $NetBSD: getguess.c,v 1.5 1995/03/23 08:32:43 cgd Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getguess.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: getguess.c,v 1.6 2004/11/29 08:52:28 jsg Exp $"; +static char rcsid[] = "$OpenBSD: getguess.c,v 1.7 2005/04/13 02:33:07 deraadt Exp $"; #endif #endif /* not lint */ @@ -99,7 +99,7 @@ readch(void) cnt = 0; for (;;) { - if (read(0, &ch, sizeof ch) <= 0) { + if (read(STDIN_FILENO, &ch, sizeof ch) <= 0) { if (++cnt > 100) die(0); } else diff --git a/games/tetris/input.c b/games/tetris/input.c index 2bdd0686d46..6af7abeae8b 100644 --- a/games/tetris/input.c +++ b/games/tetris/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.11 2004/07/10 07:26:24 deraadt Exp $ */ +/* $OpenBSD: input.c,v 1.12 2005/04/13 02:33:08 deraadt Exp $ */ /* $NetBSD: input.c,v 1.3 1996/02/06 22:47:33 jtc Exp $ */ /*- @@ -131,7 +131,7 @@ tsleep(void) tv.tv_sec = 0; tv.tv_usec = fallrate; while (TV_POS(&tv)) - if (rwait(&tv) && read(0, &c, 1) != 1) + if (rwait(&tv) && read(STDIN_FILENO, &c, 1) != 1) break; } @@ -160,7 +160,7 @@ tgetchar(void) } if (!rwait(&timeleft)) return (-1); - if (read(0, &c, 1) != 1) + if (read(STDIN_FILENO, &c, 1) != 1) stop("end of file, help"); return ((int)(unsigned char)c); } diff --git a/libexec/lockspool/lockspool.c b/libexec/lockspool/lockspool.c index a2a56addebe..200f6d815df 100644 --- a/libexec/lockspool/lockspool.c +++ b/libexec/lockspool/lockspool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lockspool.c,v 1.10 2003/07/10 00:04:28 david Exp $ */ +/* $OpenBSD: lockspool.c,v 1.11 2005/04/13 02:33:09 deraadt Exp $ */ /* * Copyright (c) 1998 Theo de Raadt @@ -27,7 +27,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: lockspool.c,v 1.10 2003/07/10 00:04:28 david Exp $"; +static const char rcsid[] = "$OpenBSD: lockspool.c,v 1.11 2005/04/13 02:33:09 deraadt Exp $"; #endif /* not lint */ #include @@ -87,7 +87,7 @@ main(int argc, char *argv[]) } write(STDOUT_FILENO, "1\n", 2); - while (read(0, &c, 1) == -1 && errno == EINTR) + while (read(STDIN_FILENO, &c, 1) == -1 && errno == EINTR) ; rellock(); exit (0); diff --git a/libexec/uucpd/uucpd.c b/libexec/uucpd/uucpd.c index 555e788dd0e..c9400fad567 100644 --- a/libexec/uucpd/uucpd.c +++ b/libexec/uucpd/uucpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uucpd.c,v 1.29 2004/06/02 02:21:15 brad Exp $ */ +/* $OpenBSD: uucpd.c,v 1.30 2005/04/13 02:33:09 deraadt Exp $ */ /* * Copyright (c) 1985 The Regents of the University of California. @@ -40,7 +40,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)uucpd.c 5.10 (Berkeley) 2/26/91";*/ -static char rcsid[] = "$OpenBSD: uucpd.c,v 1.29 2004/06/02 02:21:15 brad Exp $"; +static char rcsid[] = "$OpenBSD: uucpd.c,v 1.30 2005/04/13 02:33:09 deraadt Exp $"; #endif /* not lint */ /* @@ -229,7 +229,7 @@ readline(char *p, int n) char c; while (n-- > 0) { - if (read(0, &c, 1) <= 0) + if (read(STDIN_FILENO, &c, 1) <= 0) return(-1); c &= 0177; if (c == '\r') { diff --git a/sbin/scsi/scsi.c b/sbin/scsi/scsi.c index 56858794cde..14d3c409f4e 100644 --- a/sbin/scsi/scsi.c +++ b/sbin/scsi/scsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi.c,v 1.18 2005/04/11 22:02:06 cloder Exp $ */ +/* $OpenBSD: scsi.c,v 1.19 2005/04/13 02:33:08 deraadt Exp $ */ /* $FreeBSD: scsi.c,v 1.11 1996/04/06 11:00:28 joerg Exp $ */ /* @@ -343,26 +343,23 @@ do_cmd(int fd, char *fmt, int argc, char **argv) } count = scsireq->datalen = iget(&h, 0); - if (count) - { + if (count) { data_fmt = cget(&h, 0); scsireq->databuf = malloc(count); - if (data_phase == out) - { - if (strcmp(data_fmt, "-") == 0) /* Read data from stdin */ - { + if (data_phase == out) { + if (strcmp(data_fmt, "-") == 0) { bp = (char *)scsireq->databuf; - while (count > 0 && (amount = read(0, bp, count)) > 0) - { + while (count > 0 && + (amount = read(STDIN_FILENO, + bp, count)) > 0) { count -= amount; bp += amount; } if (amount == -1) err(errno, "read"); - else if (amount == 0) - { + else if (amount == 0) { /* early EOF */ fprintf(stderr, "Warning: only read %lu bytes out of %lu.\n", diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 469000e97ee..0697b3466e4 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: job.c,v 1.58 2004/11/29 06:20:03 jsg Exp $ */ +/* $OpenBSD: job.c,v 1.59 2005/04/13 02:33:08 deraadt Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* @@ -1336,7 +1336,7 @@ JobExec(Job *job, char **argv) (void)execv(shellPath, argv); - (void)write(2, "Could not execute shell\n", + (void)write(STDERR_FILENO, "Could not execute shell\n", sizeof("Could not execute shell")); _exit(1); } else { diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c index 2858f1c99d4..782ac22bda4 100644 --- a/usr.bin/mg/ttyio.c +++ b/usr.bin/mg/ttyio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttyio.c,v 1.26 2005/04/03 02:09:28 db Exp $ */ +/* $OpenBSD: ttyio.c,v 1.27 2005/04/13 02:33:08 deraadt Exp $ */ /* * POSIX terminal I/O. @@ -162,7 +162,7 @@ ttgetc(void) int ret; do { - ret = read(0, &c, 1); + ret = read(STDIN_FILENO, &c, 1); if (ret == -1 && errno == EINTR) { if (winch_flag) { refresh(0, 0); diff --git a/usr.bin/oldrdist/server.c b/usr.bin/oldrdist/server.c index ff68cc4343d..db1c6d6a7aa 100644 --- a/usr.bin/oldrdist/server.c +++ b/usr.bin/oldrdist/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.27 2004/10/04 05:21:27 jsg Exp $ */ +/* $OpenBSD: server.c,v 1.28 2005/04/13 02:33:08 deraadt Exp $ */ /* * Copyright (c) 1983, 1993 @@ -31,7 +31,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93"; */ -static char *rcsid = "$OpenBSD: server.c,v 1.27 2004/10/04 05:21:27 jsg Exp $"; +static char *rcsid = "$OpenBSD: server.c,v 1.28 2005/04/13 02:33:08 deraadt Exp $"; #endif /* not lint */ #include @@ -632,7 +632,7 @@ again: if (*s != '\n') { if (!iamremote) { fflush(stdout); - (void) write(2, s, cp - s); + (void) write(STDERR_FILENO, s, cp - s); } if (lfp != NULL) (void) fwrite(s, 1, cp - s, lfp); @@ -1198,7 +1198,7 @@ rmchk(opts) if (*s != '\n') { if (!iamremote) { fflush(stdout); - (void) write(2, s, cp - s); + (void) write(STDERR_FILENO, s, cp - s); } if (lfp != NULL) (void) fwrite(s, 1, cp - s, lfp); @@ -1547,7 +1547,7 @@ response() if (*s != '\n') { if (!iamremote) { fflush(stdout); - (void) write(2, s, cp - s); + (void) write(STDERR_FILENO, s, cp - s); } if (lfp != NULL) (void) fwrite(s, 1, cp - s, lfp); diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c index f23558222e7..eb58b8f6eab 100644 --- a/usr.bin/talk/io.c +++ b/usr.bin/talk/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.15 2004/03/02 21:04:42 tedu Exp $ */ +/* $OpenBSD: io.c,v 1.16 2005/04/13 02:33:08 deraadt Exp $ */ /* $NetBSD: io.c,v 1.4 1994/12/09 02:14:20 jtc Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93"; #endif -static const char rcsid[] = "$OpenBSD: io.c,v 1.15 2004/03/02 21:04:42 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: io.c,v 1.16 2005/04/13 02:33:08 deraadt Exp $"; #endif /* not lint */ /* @@ -109,7 +109,7 @@ talk(void) * curses's output routines would screw up */ ioctl(0, FIONREAD, &nb); - nb = read(0, buf, nb); + nb = read(STDIN_FILENO, buf, nb); display(&my_win, buf, nb); /* might lose data here because sockt is non-blocking */ write(sockt, buf, nb); diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index 243fdc6af4f..f5d1e289c77 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.18 2004/06/13 18:49:02 otto Exp $ */ +/* $OpenBSD: display.c,v 1.19 2005/04/13 02:33:09 deraadt Exp $ */ /* * Top users/processes display for Unix @@ -764,7 +764,7 @@ readline(char *buffer, int size, int numeric) size -= 1; /* read loop */ - while ((fflush(stdout), (len = read(0, ptr, 1)) > 0)) { + while ((fflush(stdout), (len = read(STDIN_FILENO, ptr, 1)) > 0)) { if (len == 0 || leaveflag) { end_screen(); diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index b53d0e1cda5..54d2ecbe36c 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -1,4 +1,4 @@ -/* $OpenBSD: top.c,v 1.35 2004/10/07 06:26:12 otto Exp $ */ +/* $OpenBSD: top.c,v 1.36 2005/04/13 02:33:09 deraadt Exp $ */ /* * Top users/processes display for Unix @@ -593,7 +593,7 @@ rundisplay(void) * command strchr */ while (1) { - len = read(0, &ch, 1); + len = read(STDIN_FILENO, &ch, 1); if (len == -1 && errno == EINTR) continue; if (len == 0) @@ -650,7 +650,7 @@ rundisplay(void) standout("Hit any key to continue: "); fflush(stdout); while (1) { - len = read(0, &ch, 1); + len = read(STDIN_FILENO, &ch, 1); if (len == -1 && errno == EINTR) continue; if (len == 0) @@ -673,7 +673,7 @@ rundisplay(void) standout("Hit any key to continue: "); fflush(stdout); while (1) { - len = read(0, &ch, 1); + len = read(STDIN_FILENO, &ch, 1); if (len == -1 && errno == EINTR) continue; if (len == 0) diff --git a/usr.bin/window/wwrint.c b/usr.bin/window/wwrint.c index c5600347c2d..306d074b1ff 100644 --- a/usr.bin/window/wwrint.c +++ b/usr.bin/window/wwrint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wwrint.c,v 1.7 2003/08/01 22:01:38 david Exp $ */ +/* $OpenBSD: wwrint.c,v 1.8 2005/04/13 02:33:09 deraadt Exp $ */ /* $NetBSD: wwrint.c,v 1.4 1995/12/21 10:46:24 mycroft Exp $ */ /* @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)wwrint.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: wwrint.c,v 1.7 2003/08/01 22:01:38 david Exp $"; +static char rcsid[] = "$OpenBSD: wwrint.c,v 1.8 2005/04/13 02:33:09 deraadt Exp $"; #endif #endif /* not lint */ @@ -62,7 +62,7 @@ wwrint() int n; wwnread++; - n = read(0, wwibq, wwibe - wwibq); + n = read(STDIN_FILENO, wwibq, wwibe - wwibq); if (n > 0) { if (tt.tt_rint) n = (*tt.tt_rint)(wwibq, n); diff --git a/usr.sbin/popa3d/protocol.c b/usr.sbin/popa3d/protocol.c index 0b77131024e..0ae47dd4b82 100644 --- a/usr.sbin/popa3d/protocol.c +++ b/usr.sbin/popa3d/protocol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: protocol.c,v 1.3 2003/05/12 19:28:22 camield Exp $ */ +/* $OpenBSD: protocol.c,v 1.4 2005/04/13 02:33:09 deraadt Exp $ */ /* * POP protocol handling. @@ -52,7 +52,7 @@ static void pop_fetch(void) signal(SIGALRM, pop_timeout); alarm(POP_TIMEOUT); - size = read(0, pop_buffer.data, sizeof(pop_buffer.data)); + size = read(STDIN_FILENO, pop_buffer.data, sizeof(pop_buffer.data)); alarm(0); signal(SIGALRM, SIG_DFL); -- cgit v1.2.3