diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-12-19 20:11:13 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-12-19 20:11:13 -0500 |
commit | a60b397d75e121232b8066db7333b82a6f9a951c (patch) | |
tree | fb04343461ccca86197177c8bd5572b2681147f8 /libsbutil | |
parent | libsandbox: switch to PTRACE_O_TRACEEXEC (diff) | |
download | sandbox-a60b397d75e121232b8066db7333b82a6f9a951c.tar.gz sandbox-a60b397d75e121232b8066db7333b82a6f9a951c.tar.bz2 sandbox-a60b397d75e121232b8066db7333b82a6f9a951c.zip |
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@gentoo.org>
Diffstat (limited to 'libsbutil')
-rw-r--r-- | libsbutil/sb_efuncs.c | 16 |
1 files 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, ...) |