aboutsummaryrefslogtreecommitdiffstats
path: root/libgamma_strerror_r.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-11-20 15:45:17 +0100
committerMattias Andrée <m@maandree.se>2026-11-20 15:45:17 +0100
commit6421c8217b38d7b5605c652b89793b2de0192d91 (patch)
tree5234e86fc5d223be29e0751b0e6165d26ba12f55 /libgamma_strerror_r.c
parentfix typo (diff)
downloadlibgamma-6421c8217b38d7b5605c652b89793b2de0192d91.tar.gz
libgamma-6421c8217b38d7b5605c652b89793b2de0192d91.tar.bz2
libgamma-6421c8217b38d7b5605c652b89793b2de0192d91.tar.xz
Add libgamma_get_fd and fix some minor issuesHEAD0.9master
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libgamma_strerror_r.c')
-rw-r--r--libgamma_strerror_r.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/libgamma_strerror_r.c b/libgamma_strerror_r.c
index c95d8a9..1076ed8 100644
--- a/libgamma_strerror_r.c
+++ b/libgamma_strerror_r.c
@@ -2,6 +2,22 @@
#include "common.h"
+static const char *
+libgamma_xsi_strerror_r(int (*function)(int, char *, size_t), int error_code, char *buf, size_t bufsize)
+{
+ int error = function(error_code, buf, bufsize);
+ errno = error;
+ return error ? NULL : buf;
+}
+
+
+static const char *
+libgamma_gnu_strerror_r(char *(*function)(int, char *, size_t), int error_code, char *buf, size_t bufsize)
+{
+ return function(error_code, buf, bufsize);
+}
+
+
/**
* Get a description of an error
*
@@ -36,11 +52,12 @@ libgamma_strerror_r(int error_code, char buf[], size_t bufsize)
*buf = '\0';
if (error_code >= 0) {
saved_errno = errno;
- desc = _Generic(strerror_r(error_code, buf, bufsize),
+ desc = _Generic(&strerror_r,
/* XSI strerror_r */
- int: (errno = (int)(intptr_t)strerror_r(error_code, buf, bufsize)) ? NULL : buf,
+ int (*)(int, char *, size_t): libgamma_xsi_strerror_r,
/* GNU strerror_r */
- char *: (char *)(intptr_t)strerror_r(error_code, buf, bufsize));
+ char *(*)(int, char *, size_t): libgamma_gnu_strerror_r)
+ (&strerror_r, error_code, buf, bufsize);
if (desc == buf && (!bufsize || !*buf))
desc = NULL;
if (desc) {