summaryrefslogtreecommitdiffstats
path: root/common/misc.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:01:54 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:01:54 +0200
commit5335912a97fce052b84bf58513d4ba119aab7ec6 (patch)
treedf51436c2b45ad189f85e4c042b9044c555e2fc0 /common/misc.c
parentbe8b9a1abbbf2f3ea9da540f21279c7fe1191749 (diff)
downloadbarebox-5335912a97fce052b84bf58513d4ba119aab7ec6.tar.gz
svn_rev_441
add errno_str()
Diffstat (limited to 'common/misc.c')
-rw-r--r--common/misc.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/common/misc.c b/common/misc.c
index 121d51d..d2b3455 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -14,9 +14,6 @@ void mem_malloc_init (void *start, void *end)
mem_malloc_start = (ulong)start;
mem_malloc_end = (ulong)end;
mem_malloc_brk = mem_malloc_start;
-
- memset ((void *) mem_malloc_start, 0,
- mem_malloc_end - mem_malloc_start);
}
void *sbrk (ptrdiff_t increment)
@@ -34,7 +31,11 @@ void *sbrk (ptrdiff_t increment)
int errno;
-void perror(const char *s)
+#ifndef CONFIG_ERRNO_MESSAGES
+static char errno_str[5];
+#endif
+
+const char *errno_str(void)
{
#ifdef CONFIG_ERRNO_MESSAGES
char *str;
@@ -104,9 +105,18 @@ void perror(const char *s)
default : str = "unknown error"; break;
};
- printf("%s: %s\n", s, str);
+ return str;
#else
- printf("%s returned with %d\n", s, errno);
+ sprintf(errno_str, "%d", errno);
+ return errno_str;
#endif
}
+void perror(const char *s)
+{
+#ifdef CONFIG_ERRNO_MESSAGES
+ printf("%s: %s\n", s, errno_str());
+#else
+ printf("%s returned with %d\n", s, errno);
+#endif
+}