summaryrefslogtreecommitdiff
path: root/os/log.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-11-27 22:34:57 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2010-11-30 16:25:22 -0800
commit8f42b2b69387b006bfcd373c3d023ebea9035db2 (patch)
treeb44db74079f3de6fd514f16b05fe3e1c5d1c9e49 /os/log.c
parent685286b17d30335d799a9da11914943e466ea955 (diff)
Simplify Error() - don't allocate temporary copy of error string
Doesn't seem to be any reason to just not pass the error string as another argument directly to LogVWrite() Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Julien Cristau <jcristau@debian.org>
Diffstat (limited to 'os/log.c')
-rw-r--r--os/log.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/os/log.c b/os/log.c
index d77708ea6..fdcf91c31 100644
--- a/os/log.c
+++ b/os/log.c
@@ -571,21 +571,14 @@ ErrorF(const char * f, ...)
/* A perror() workalike. */
void
-Error(char *str)
+Error(const char *str)
{
- char *err = NULL;
- int saveErrno = errno;
-
- if (str) {
- err = malloc(strlen(strerror(saveErrno)) + strlen(str) + 2 + 1);
- if (!err)
- return;
- sprintf(err, "%s: ", str);
- strcat(err, strerror(saveErrno));
+ const char *err = strerror(errno);
+
+ if (str)
+ LogWrite(-1, "%s: %s", str, err);
+ else
LogWrite(-1, "%s", err);
- free(err);
- } else
- LogWrite(-1, "%s", strerror(saveErrno));
}
void