From: Bartosz Golaszewski Date: Mon, 9 Jan 2017 11:37:04 +0000 (+0100) Subject: core: implement gpiod_last_strerror() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=9540285a7b3d470968b4b094ae8de71d06a8b650;p=qemu-gpiodev%2Flibgpiod.git 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 --- 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; + /** * @} *