diff options
author | 2010-08-12 02:00:27 +0000 | |
---|---|---|
committer | 2010-08-12 02:00:27 +0000 | |
commit | 8af2993faa11236d68a01e9bb5c5eef4c25d719c (patch) | |
tree | e8b33f3d86acf701373321b19d1e5bff8c083bce | |
parent | Initialize xs to NULL in gdt_intr() since it now might be used before (diff) | |
download | wireguard-openbsd-8af2993faa11236d68a01e9bb5c5eef4c25d719c.tar.xz wireguard-openbsd-8af2993faa11236d68a01e9bb5c5eef4c25d719c.zip |
Use symbolic names for the file descriptors rather than numeric values.
Some from damien@, millert@
ok phessler@, millert@
-rw-r--r-- | bin/csh/dol.c | 13 | ||||
-rw-r--r-- | bin/csh/sem.c | 10 | ||||
-rw-r--r-- | bin/ed/main.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/pppctl/pppctl.c | 12 | ||||
-rw-r--r-- | usr.sbin/pppd/chat/chat.c | 10 |
5 files changed, 27 insertions, 26 deletions
diff --git a/bin/csh/dol.c b/bin/csh/dol.c index fcb4819c997..864a7906657 100644 --- a/bin/csh/dol.c +++ b/bin/csh/dol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dol.c,v 1.16 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: dol.c,v 1.17 2010/08/12 02:00:27 kevlo Exp $ */ /* $NetBSD: dol.c,v 1.8 1995/09/27 00:38:38 jtc Exp $ */ /*- @@ -862,8 +862,9 @@ heredoc(Char *term) * Check for EOF or compare to terminator -- before expansion */ if (c < 0 || eq(lbuf, term)) { - (void) write(0, short2str(obuf), (size_t) (BUFSIZ - ocnt)); - (void) lseek(0, (off_t) 0, SEEK_SET); + (void) write(STDIN_FILENO, short2str(obuf), + (size_t) (BUFSIZ - ocnt)); + (void) lseek(STDIN_FILENO, (off_t) 0, SEEK_SET); return; } @@ -876,7 +877,7 @@ heredoc(Char *term) for (lbp = lbuf; (c = *lbp++) != '\0';) { *obp++ = c; if (--ocnt == 0) { - (void) write(0, short2str(obuf), BUFSIZ); + (void) write(STDIN_FILENO, short2str(obuf), BUFSIZ); obp = obuf; ocnt = BUFSIZ; } @@ -940,14 +941,14 @@ heredoc(Char *term) for (mbp = *vp; *mbp; mbp++) { *obp++ = *mbp & TRIM; if (--ocnt == 0) { - (void) write(0, short2str(obuf), BUFSIZ); + (void) write(STDIN_FILENO, short2str(obuf), BUFSIZ); obp = obuf; ocnt = BUFSIZ; } } *obp++ = '\n'; if (--ocnt == 0) { - (void) write(0, short2str(obuf), BUFSIZ); + (void) write(STDIN_FILENO, short2str(obuf), BUFSIZ); obp = obuf; ocnt = BUFSIZ; } diff --git a/bin/csh/sem.c b/bin/csh/sem.c index c4d0255dadc..3d4d0428ffe 100644 --- a/bin/csh/sem.c +++ b/bin/csh/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.16 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: sem.c,v 1.17 2010/08/12 02:00:27 kevlo Exp $ */ /* $NetBSD: sem.c,v 1.9 1995/09/27 00:38:50 jtc Exp $ */ /*- @@ -546,7 +546,7 @@ doio(struct command *t, int *pipein, int *pipeout) else { (void) close(0); (void) dup(OLDSTD); - (void) ioctl(0, FIONCLEX, NULL); + (void) ioctl(STDIN_FILENO, FIONCLEX, NULL); } } if (t->t_drit) { @@ -565,7 +565,7 @@ doio(struct command *t, int *pipein, int *pipeout) (fd = open(tmp, O_WRONLY | O_APPEND)) >= 0); #else (fd = open(tmp, O_WRONLY)) >= 0) - (void) lseek(1, (off_t) 0, SEEK_END); + (void) lseek(STDOUT_FILENO, (off_t) 0, SEEK_END); #endif else { if (!(flags & F_OVERWRITE) && adrof(STRnoclobber)) { @@ -585,7 +585,7 @@ doio(struct command *t, int *pipein, int *pipeout) else { (void) close(1); (void) dup(SHOUT); - (void) ioctl(1, FIONCLEX, NULL); + (void) ioctl(STDOUT_FILENO, FIONCLEX, NULL); } (void) close(2); @@ -594,7 +594,7 @@ doio(struct command *t, int *pipein, int *pipeout) } else { (void) dup(SHERR); - (void) ioctl(2, FIONCLEX, NULL); + (void) ioctl(STDERR_FILENO, FIONCLEX, NULL); } didfds = 1; } diff --git a/bin/ed/main.c b/bin/ed/main.c index a12f83aeaca..92943b53cae 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.33 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.34 2010/08/12 02:00:28 kevlo Exp $ */ /* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */ /* main.c: This file contains the main control and user-interface routines @@ -150,8 +150,8 @@ top: struct stat sb; /* assert: pipes show up as fifo's when fstat'd */ - if (fstat(0, &sb) || !S_ISFIFO(sb.st_mode)) { - if (lseek(0, 0, SEEK_CUR)) { + if (fstat(STDIN_FILENO, &sb) || !S_ISFIFO(sb.st_mode)) { + if (lseek(STDIN_FILENO, 0, SEEK_CUR)) { interactive = 1; setlinebuf(stdout); } @@ -1436,7 +1436,7 @@ handle_winch(int signo) struct winsize ws; /* window size structure */ sigflags &= ~(1 << (signo - 1)); - if (ioctl(0, TIOCGWINSZ, &ws) >= 0) { + if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) >= 0) { if (ws.ws_row > 2) rows = ws.ws_row - 2; if (ws.ws_col > 8) diff --git a/usr.sbin/ppp/pppctl/pppctl.c b/usr.sbin/ppp/pppctl/pppctl.c index f5512c4f8be..f8dcbfd3005 100644 --- a/usr.sbin/ppp/pppctl/pppctl.c +++ b/usr.sbin/ppp/pppctl/pppctl.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pppctl.c,v 1.20 2008/11/12 16:01:08 sobrado Exp $ + * $Id: pppctl.c,v 1.21 2010/08/12 02:00:28 kevlo Exp $ */ #include <sys/types.h> @@ -109,7 +109,7 @@ Receive(int fd, int display) last = prompt; if (last) { last++; - write(1, Buffer, last-Buffer); + write(STDOUT_FILENO, Buffer, last-Buffer); } } prompt = prompt == NULL ? Buffer : prompt+1; @@ -125,7 +125,7 @@ Receive(int fd, int display) snprintf(Buffer, sizeof Buffer, "passwd %s\n", passwd); memset(passwd, '\0', strlen(passwd)); if (display & REC_VERBOSE) - write(1, Buffer, strlen(Buffer)); + write(STDOUT_FILENO, Buffer, strlen(Buffer)); write(fd, Buffer, strlen(Buffer)); memset(Buffer, '\0', strlen(Buffer)); return Receive(fd, display & ~REC_PASSWD); @@ -142,7 +142,7 @@ Receive(int fd, int display) flush = sizeof Buffer / 2; else flush = last - Buffer + 1; - write(1, Buffer, flush); + write(STDOUT_FILENO, Buffer, flush); strlcpy(Buffer, Buffer + flush, sizeof Buffer); len -= flush; } @@ -167,7 +167,7 @@ check_fd(int sig) if (poll(pfd, 1, 0) > 0) { len = read(data, buf, sizeof buf); if (len > 0) - write(1, buf, len); + write(STDOUT_FILENO, buf, len); else longjmp(pppdead, -1); } @@ -467,7 +467,7 @@ main(int argc, char **argv) Buffer[sizeof(Buffer)-2] = '\0'; strlcat(Buffer, "\n", sizeof Buffer); if (verbose) - write(1, Buffer, strlen(Buffer)); + write(STDOUT_FILENO, Buffer, strlen(Buffer)); write(fd, Buffer, strlen(Buffer)); if (Receive(fd, verbose | REC_SHOW) != 0) { fprintf(stderr, "Connection closed\n"); diff --git a/usr.sbin/pppd/chat/chat.c b/usr.sbin/pppd/chat/chat.c index 1ac55b272b9..32a8da678c5 100644 --- a/usr.sbin/pppd/chat/chat.c +++ b/usr.sbin/pppd/chat/chat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chat.c,v 1.27 2009/10/27 23:59:53 deraadt Exp $ */ +/* $OpenBSD: chat.c,v 1.28 2010/08/12 02:00:28 kevlo Exp $ */ /* * Chat -- a program for automatic session establishment (i.e. dial @@ -980,7 +980,7 @@ register char *s; if (say_next) { say_next = 0; s = clean(s,0); - write(2, s, strlen(s)); + write(STDERR_FILENO, s, strlen(s)); free(s); return; } @@ -1157,7 +1157,7 @@ int c; usleep(10000); /* inter-character typing delay (?) */ - status = write(1, &ch, 1); + status = write(STDOUT_FILENO, &ch, 1); switch (status) { case 1: @@ -1264,12 +1264,12 @@ int n; break; /* fall through */ case '\n': - write(2, "\n", 1); + write(STDERR_FILENO, "\n", 1); need_lf = 0; break; default: s = character(n); - write(2, s, strlen(s)); + write(STDERR_FILENO, s, strlen(s)); need_lf = 1; break; } |