summaryrefslogtreecommitdiff
path: root/os/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/log.c')
-rw-r--r--os/log.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/os/log.c b/os/log.c
index 3961b0b9f..8108890b6 100644
--- a/os/log.c
+++ b/os/log.c
@@ -316,7 +316,7 @@ void
LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
{
const char *s = X_UNKNOWN_STRING;
- char *tmpBuf = NULL;
+ char tmpBuf[1024];
/* Ignore verbosity for X_ERROR */
if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) {
@@ -358,21 +358,11 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
break;
}
- /*
- * Prefix the format string with the message type. We do it this way
- * so that LogVWrite() is only called once per message.
- */
- if (s) {
- tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1);
- /* Silently return if malloc fails here. */
- if (!tmpBuf)
- return;
- sprintf(tmpBuf, "%s ", s);
- strcat(tmpBuf, format);
- LogVWrite(verb, tmpBuf, args);
- free(tmpBuf);
- } else
- LogVWrite(verb, format, args);
+ /* if s is not NULL we need a space before format */
+ snprintf(tmpBuf, sizeof(tmpBuf), "%s%s%s", s ? s : "",
+ s ? " " : "",
+ format);
+ LogVWrite(verb, tmpBuf, args);
}
}