From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: libsbutil/
Date: Sun, 20 Dec 2015 08:41:18 +0000 (UTC) [thread overview]
Message-ID: <1450573873.a60b397d75e121232b8066db7333b82a6f9a951c.vapier@gentoo> (raw)
commit: a60b397d75e121232b8066db7333b82a6f9a951c
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 20 01:11:13 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> 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 <vapier <AT> 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, ...)
next reply other threads:[~2015-12-20 8:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-20 8:41 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-03-09 18:09 [gentoo-commits] proj/sandbox:master commit in: libsbutil/ Mike Gilbert
2023-07-17 13:54 Mike Gilbert
2021-11-05 10:25 Mike Frysinger
2021-11-03 21:10 Andreas K. Hüttel
2021-11-03 4:59 Mike Frysinger
2021-10-18 8:48 Mike Frysinger
2016-11-27 18:31 Mike Frysinger
2016-01-18 6:18 Mike Frysinger
2015-09-20 8:15 Mike Frysinger
2015-09-11 7:53 Mike Frysinger
2015-09-11 7:53 Mike Frysinger
2015-09-11 7:53 Mike Frysinger
2013-02-25 4:08 Mike Frysinger
2012-12-24 5:23 Mike Frysinger
2012-12-24 5:19 Mike Frysinger
2012-11-26 10:10 Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450573873.a60b397d75e121232b8066db7333b82a6f9a951c.vapier@gentoo \
--to=vapier@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox