zephyr/lib/posix/perror.c
Christopher Friedt b391993d1b lib: posix: add perror() implementation
Add a trivial implementation of `perror()`.

Fixes #46100

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-07-04 22:53:36 +02:00

19 lines
344 B
C

/*
* Copyright (c) 2022 Meta
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
/*
* See https://pubs.opengroup.org/onlinepubs/9699919799/functions/perror.html
*/
void perror(const char *s)
{
fprintf(stderr, "%s%s%s\n", s == NULL ? "" : s, s == NULL ? "" : ": ",
strerror(errno));
}