aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-12-20 01:00:07 -0500
committerMike Frysinger <vapier@gentoo.org>2015-12-20 01:00:07 -0500
commit95a3da9888af86a93732be4964da6aed5e523fcd (patch)
tree9517e2587b1ca698721dfa86eee65ce8ffd686a2 /libsbutil
parentsb_efuncs: avoid pointless stdio indirection (diff)
downloadsandbox-95a3da9888af86a93732be4964da6aed5e523fcd.tar.gz
sandbox-95a3da9888af86a93732be4964da6aed5e523fcd.tar.bz2
sandbox-95a3da9888af86a93732be4964da6aed5e523fcd.zip
libsandbox: avoid mixing stderr & output pipes
The various debug helpers were changed to write out to a dedicated message path, but some of the trace code still uses stderr directly. When mixing these methods, the direct prints would sometimes be lost. Convert the few users to a new raw print function so they all route through the same file. We might want to extract this a bit more out in the future so it's easier to write to them, but this should be fine for now. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil')
-rw-r--r--libsbutil/sb_efuncs.c14
-rw-r--r--libsbutil/sbutil.h1
2 files changed, 14 insertions, 1 deletions
diff --git a/libsbutil/sb_efuncs.c b/libsbutil/sb_efuncs.c
index 2de3116..7ded90d 100644
--- a/libsbutil/sb_efuncs.c
+++ b/libsbutil/sb_efuncs.c
@@ -48,7 +48,8 @@ static void sb_vefunc(const char *prog, const char *color, const char *format, v
if (fd == -1)
fd = fileno(stderr);
- sb_fdprintf(fd, " %s*%s ", color, COLOR_NORMAL);
+ if (color)
+ sb_fdprintf(fd, " %s*%s ", color, COLOR_NORMAL);
sb_vfdprintf(fd, format, args);
if (opened)
@@ -98,6 +99,17 @@ void sb_eqawarn(const char *format, ...)
va_end(args);
}
+/* This is a bit of a hack to expose the same file logic to generic printers.
+ * Probably want to revisit sb_vefunc and move the guts there to a new func.
+ */
+void sb_eraw(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ sb_vefunc(NULL, NULL, format, args);
+ va_end(args);
+}
+
void sb_dump_backtrace(void)
{
#ifdef HAVE_BACKTRACE
diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index 15979da..66c6f73 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -112,6 +112,7 @@ __printf(1, 2) void sb_ewarn(const char *format, ...);
__printf(1, 2) void sb_eerror(const char *format, ...);
__printf(1, 2) void sb_eqawarn(const char *format, ...);
__printf(1, 2) void sb_debug_dyn(const char *format, ...);
+__printf(1, 2) void sb_eraw(const char *format, ...);
__printf(4, 5) void __sb_ebort(const char *file, const char *func, size_t line_num, const char *format, ...) __noreturn;
#define sb_ebort(format, ...) __sb_ebort(__FILE__, __func__, __LINE__, format, ## __VA_ARGS__)
void sb_dump_backtrace(void);