aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/os/log.c')
-rw-r--r--xorg-server/os/log.c69
1 files changed, 12 insertions, 57 deletions
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index 282d2b97c..ef34b1afe 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -318,7 +318,7 @@ _X_EXPORT 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) {
@@ -360,21 +360,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);
}
}
@@ -417,9 +407,7 @@ AbortServer(void)
exit (1);
}
-#ifndef AUDIT_PREFIX
-#define AUDIT_PREFIX "AUDIT: %s: %ld %s: "
-#endif
+#define AUDIT_PREFIX "AUDIT: %s: %ld: "
#ifndef AUDIT_TIMEOUT
#define AUDIT_TIMEOUT ((CARD32)(120 * 1000)) /* 2 mn */
#endif
@@ -451,15 +439,11 @@ AuditPrefix(void)
autime = ctime(&tm);
if ((s = strchr(autime, '\n')))
*s = '\0';
- if ((s = strrchr(argvGlobal[0], '/')))
- s++;
- else
- s = argvGlobal[0];
- len = strlen(AUDIT_PREFIX) + strlen(autime) + 10 + strlen(s) + 1;
+ len = strlen(AUDIT_PREFIX) + strlen(autime) + 10 + 1;
tmpBuf = malloc(len);
if (!tmpBuf)
return NULL;
- snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long)getpid(), s);
+ snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long)getpid());
return tmpBuf;
}
@@ -505,15 +489,6 @@ VAuditF(const char *f, va_list args)
prefix = AuditPrefix();
len = vsnprintf(buf, sizeof(buf), f, args);
-#if 1
- /* XXX Compressing duplicated messages is temporarily disabled to
- * work around bugzilla 964:
- * https://freedesktop.org/bugzilla/show_bug.cgi?id=964
- */
- ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
- oldlen = -1;
- nrepeat = 0;
-#else
if (len == oldlen && strcmp(buf, oldbuf) == 0) {
/* Message already seen */
nrepeat++;
@@ -527,7 +502,6 @@ VAuditF(const char *f, va_list args)
nrepeat = 0;
auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);
}
-#endif
if (prefix != NULL)
free(prefix);
}
@@ -547,13 +521,8 @@ FatalError(const char *f, ...)
VErrorF(f, args);
va_end(args);
ErrorF("\n");
-#ifdef DDXOSFATALERROR
if (!beenhere)
OsVendorFatalError();
-#endif
-#ifdef ABORTONFATALERROR
- abort();
-#endif
if (!beenhere) {
beenhere = TRUE;
AbortServer();
@@ -587,21 +556,6 @@ ErrorF(const char * f, ...)
/* A perror() workalike. */
-#ifndef NEED_STRERROR
-#ifdef SYSV
-#if !defined(ISC) || defined(ISC202) || defined(ISC22)
-#define NEED_STRERROR
-#endif
-#endif
-#endif
-
-#if defined(NEED_STRERROR) && !defined(strerror)
-extern char *sys_errlist[];
-extern int sys_nerr;
-#define strerror(n) \
- ((n) >= 0 && (n) < sys_nerr) ? sys_errlist[(n)] : "unknown error"
-#endif
-
_X_EXPORT void
Error(char *str)
{
@@ -614,9 +568,10 @@ Error(char *str)
return;
sprintf(err, "%s: ", str);
strcat(err, strerror(saveErrno));
- LogWrite(-1, err);
+ LogWrite(-1, "%s", err);
+ free(err);
} else
- LogWrite(-1, strerror(saveErrno));
+ LogWrite(-1, "%s", strerror(saveErrno));
}
void