summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-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