From: guenther Date: Sun, 11 Oct 2015 00:20:29 +0000 (+0000) Subject: Prefer dprintf() over snprintf()+write() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=633a11795a5b6434616348d92d13dd60822b0601;p=openbsd Prefer dprintf() over snprintf()+write() ok beck@ deraadt@ --- diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 6452f8ab1cc..6ab3b55bfc8 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.92 2015/08/20 22:02:21 deraadt Exp $ */ +/* $OpenBSD: mkfs.c,v 1.93 2015/10/11 00:20:29 guenther Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -154,11 +154,9 @@ void siginfo(int sig) { int save_errno = errno; - char buf[128]; - snprintf(buf, sizeof(buf), "%s: initializing cg %ld/%d\n", + dprintf(STDERR_FILENO, "%s: initializing cg %ld/%d\n", cur_fsys, (long)cur_cylno, sblock.fs_ncg); - write(STDERR_FILENO, buf, strlen(buf)); errno = save_errno; } #endif diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 57af30bf1be..9b5b7d4e0b4 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.127 2015/10/09 01:37:06 deraadt Exp $ */ +/* $OpenBSD: ping.c,v 1.128 2015/10/11 00:20:29 guenther Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -623,7 +623,6 @@ void pinger(void) { struct icmp *icp; - char buf[8192]; int cc, i; u_char *packet = outpack; @@ -688,9 +687,8 @@ pinger(void) if (i < 0 || i != cc) { if (i < 0) perror("ping: sendto"); - snprintf(buf, sizeof buf, "ping: wrote %s %d chars, ret=%d\n", + dprintf(STDOUT_FILENO, "ping: wrote %s %d chars, ret=%d\n", hostname, cc, i); - write(STDOUT_FILENO, buf, strlen(buf)); } if (!(options & F_QUIET) && options & F_FLOOD) (void)write(STDOUT_FILENO, &DOT, 1);