summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-03-26 09:45:03 +0800
committerHarald Welte <laforge@gnumonks.org>2010-03-26 21:26:01 +0800
commitd788f6688c5ef80a115fd13be4cf40ee16a85389 (patch)
tree9ba275b552a4e3378f75992e04e7efbcfeec023d
parent4a2bb9e38b10080ba4154013ba797b3ab9d7307a (diff)
debug.c: fix no-color-printing in case .color = NULL
-rw-r--r--src/debug.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/debug.c b/src/debug.c
index 934f2292..d10861f8 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -115,7 +115,7 @@ static const char* color(int subsys)
return debug_info->cat[i].color;
}
- return "";
+ return NULL;
}
static void _output(struct debug_target *target, unsigned int subsys,
@@ -136,8 +136,11 @@ static void _output(struct debug_target *target, unsigned int subsys,
/* are we using color */
if (target->use_color) {
- snprintf(col, sizeof(col), "%s", color(subsys));
- col[sizeof(col)-1] = '\0';
+ const char *c = color(subsys);
+ if (c) {
+ snprintf(col, sizeof(col), "%s", color(subsys));
+ col[sizeof(col)-1] = '\0';
+ }
}
vsnprintf(buf, sizeof(buf), format, ap);
buf[sizeof(buf)-1] = '\0';