From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 70E571384B4 for ; Sun, 20 Dec 2015 08:41:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7FE0F21C003; Sun, 20 Dec 2015 08:41:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F20BD21C008 for ; Sun, 20 Dec 2015 08:41:21 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CCB6934072E for ; Sun, 20 Dec 2015 08:41:20 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A5A56CB2 for ; Sun, 20 Dec 2015 08:41:18 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1450573873.a60b397d75e121232b8066db7333b82a6f9a951c.vapier@gentoo> Subject: [gentoo-commits] proj/sandbox:master commit in: libsbutil/ X-VCS-Repository: proj/sandbox X-VCS-Files: libsbutil/sb_efuncs.c X-VCS-Directories: libsbutil/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: a60b397d75e121232b8066db7333b82a6f9a951c X-VCS-Branch: master Date: Sun, 20 Dec 2015 08:41:18 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e6f68fc4-1032-48c8-af28-f8319a0d2bf7 X-Archives-Hash: f93f96203798a6f9032deef632e3b520 commit: a60b397d75e121232b8066db7333b82a6f9a951c Author: Mike Frysinger gentoo org> AuthorDate: Sun Dec 20 01:11:13 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sun Dec 20 01:11:13 2015 +0000 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=a60b397d sb_efuncs: avoid pointless stdio indirection We were setting up a FILE* from a file descriptor to pass to sb_fprintf which is a simple macro that calls fileno(fp) to pass the fd down. We can call the fd funcs directly and avoid the whole stdio business. Signed-off-by: Mike Frysinger gentoo.org> libsbutil/sb_efuncs.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libsbutil/sb_efuncs.c b/libsbutil/sb_efuncs.c index c855257..2de3116 100644 --- a/libsbutil/sb_efuncs.c +++ b/libsbutil/sb_efuncs.c @@ -35,8 +35,8 @@ static void sbio_init(void) */ static void sb_vefunc(const char *prog, const char *color, const char *format, va_list args) { + bool opened; int fd; - FILE *fp; if (likely(sbio_message_path)) fd = sbio_open(sbio_message_path, O_WRONLY|O_APPEND|O_CLOEXEC, 0); @@ -44,15 +44,15 @@ static void sb_vefunc(const char *prog, const char *color, const char *format, v fd = -1; if (fd == -1) fd = sbio_open(sbio_fallback_path, O_WRONLY|O_CLOEXEC, 0); - fp = fd == -1 ? NULL : fdopen(fd, "ae"); - if (!fp) - fp = stderr; + opened = (fd != -1); + if (fd == -1) + fd = fileno(stderr); - sb_fprintf(fp, " %s*%s ", color, COLOR_NORMAL); - sb_vfprintf(fp, format, args); + sb_fdprintf(fd, " %s*%s ", color, COLOR_NORMAL); + sb_vfdprintf(fd, format, args); - if (fp != stderr) - fclose(fp); + if (opened) + close(fd); } void sb_einfo(const char *format, ...)