From 9540285a7b3d470968b4b094ae8de71d06a8b650 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 9 Jan 2017 12:37:04 +0100 Subject: [PATCH] core: implement gpiod_last_strerror() This is the same as gpiod_strerror() except that it automatically uses the last error number by calling gpiod_errno(). Signed-off-by: Bartosz Golaszewski --- core.c | 5 +++++ gpiod.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/core.c b/core.c index d754e1b..de5dff2 100644 --- a/core.c +++ b/core.c @@ -130,6 +130,11 @@ const char * gpiod_strerror(int errnum) return error_descr[errnum - __GPIOD_ERRNO_OFFSET]; } +const char * gpiod_last_strerror(void) +{ + return gpiod_strerror(gpiod_errno()); +} + int gpiod_simple_get_value(const char *device, unsigned int offset, bool active_low) { diff --git a/gpiod.h b/gpiod.h index c5752c9..e75e3d2 100644 --- a/gpiod.h +++ b/gpiod.h @@ -96,6 +96,12 @@ int gpiod_errno(void) GPIOD_API; */ const char * gpiod_strerror(int errnum) GPIOD_API; +/** + * @brief Convert the last libgpiod error number to a human-readable string. + * @return Pointer to a null-terminated error description. + */ +const char * gpiod_last_strerror(void) GPIOD_API; + /** * @} * -- 2.30.2