diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-11 15:16:15 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-11 15:16:15 +0000 |
commit | ffb7a773a6090d832bc785080aafc738eb775dc4 (patch) | |
tree | 5bb82e242f5381f9e86a670cc6fbcb1db03a71c7 /sbin | |
parent | bef26dee917b1ca6458da1eef9420d30abd219f1 (diff) |
use writev; ok henning
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/errwarn.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/sbin/dhclient/errwarn.c b/sbin/dhclient/errwarn.c index 03b75478457..f6925d0cfa2 100644 --- a/sbin/dhclient/errwarn.c +++ b/sbin/dhclient/errwarn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: errwarn.c,v 1.7 2004/05/04 22:23:01 mickey Exp $ */ +/* $OpenBSD: errwarn.c,v 1.8 2005/04/11 15:16:14 deraadt Exp $ */ /* Errors and warnings... */ @@ -40,6 +40,9 @@ * with Vixie Laboratories. */ +#include <sys/types.h> +#include <sys/uio.h> +#include <unistd.h> #include <errno.h> #include "dhcpd.h" @@ -204,6 +207,7 @@ parse_warn(char *fmt, ...) static char spaces[] = " " " "; /* 80 spaces */ + struct iovec iov[6]; do_percentm(mbuf, sizeof(mbuf), fmt); snprintf(fbuf, sizeof(fbuf), "%s line %d: %s", tlname, lexline, mbuf); @@ -220,15 +224,20 @@ parse_warn(char *fmt, ...) #endif if (log_perror) { - write(2, mbuf, strlen(mbuf)); - write(2, "\n", 1); - write(2, token_line, strlen(token_line)); - write(2, "\n", 1); - write(2, spaces, lexchar - 1); - write(2, "^\n", 2); + iov[0].iov_base = mbuf; + iov[0].iov_len = strlen(mbuf); + iov[1].iov_base = "\n"; + iov[1].iov_len = 1; + iov[2].iov_base = token_line; + iov[2].iov_len = strlen(token_line); + iov[3].iov_base = "\n"; + iov[3].iov_len = 1; + iov[4].iov_base = spaces; + iov[4].iov_len = lexchar - 1; + iov[5].iov_base = "\n"; + iov[5].iov_len = 1; + writev(2, iov, sizeof(iov)/sizeof(iov[0])); } - warnings_occurred = 1; - return (0); } |