summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/perror.c
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-14 18:10:13 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-14 19:28:34 +0100
commit872cf03f26c2801ae6c3008ce5fa0d7856f5f85d (patch)
tree94809812b71ee286eb5b74c70e4d08fc4c8dc057 /lib/libc/stdio/perror.c
parentec769a83bde09c76bd6ad9ee7f391036dba5cd97 (diff)
libc: implement err/warn functions
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;