From 872cf03f26c2801ae6c3008ce5fa0d7856f5f85d Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 14 Dec 2025 18:10:13 +0100 Subject: libc: implement err/warn functions --- lib/libc/stdio/perror.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdio/perror.c') 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; -- cgit v1.2.3