summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/perror.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/perror.c')
-rw-r--r--lib/libc/stdio/perror.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdio/perror.c b/lib/libc/stdio/perror.c
index ad314038..02e14a42 100644
--- a/lib/libc/stdio/perror.c
+++ b/lib/libc/stdio/perror.c
@@ -8,19 +8,21 @@
void perror(const char *s)
{
+ char *errstr;
struct iovec iov[4];
- char *errstr = strerror(errno);
-
if (s != NULL && *s != '\0') {
iov[0].iov_base = (void *)s;
iov[0].iov_len = strlen(s);
+
iov[1].iov_base = ": ";
iov[1].iov_len = 2;
}
+ errstr = strerror(errno);
iov[s != NULL && *s != '\0' ? 2 : 0].iov_base = errstr;
iov[s != NULL && *s != '\0' ? 2 : 0].iov_len = strlen(errstr);
+
iov[s != NULL && *s != '\0' ? 3 : 1].iov_base = "\n";
iov[s != NULL && *s != '\0' ? 3 : 1].iov_len = 1;