aboutsummaryrefslogtreecommitdiffstats
path: root/libgamma_strerror.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-03-05 23:30:24 +0100
committerMattias Andrée <maandree@kth.se>2021-03-05 23:30:24 +0100
commit80a78b91c2905fcacf0236d63a9f4e3d7e576d7e (patch)
tree305419312ba536e041be28bb271118e0ccf6956b /libgamma_strerror.c
parentm (diff)
downloadlibgamma-80a78b91c2905fcacf0236d63a9f4e3d7e576d7e.tar.gz
libgamma-80a78b91c2905fcacf0236d63a9f4e3d7e576d7e.tar.bz2
libgamma-80a78b91c2905fcacf0236d63a9f4e3d7e576d7e.tar.xz
minor fixes + add tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libgamma_strerror.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/libgamma_strerror.c b/libgamma_strerror.c
index 77d4c89..8df7b46 100644
--- a/libgamma_strerror.c
+++ b/libgamma_strerror.c
@@ -14,19 +14,15 @@
const char *
libgamma_strerror(int error_code)
{
- const char *desc;
if (error_code == LIBGAMMA_ERRNO_SET)
error_code = errno;
switch (error_code) {
#define X(NAME, DESC)\
case NAME:\
- desc = DESC;\
- break;
+ return DESC;
LIST_ERRORS(X)
#undef X
default:
- desc = NULL;
- break;
+ return error_code < 0 ? NULL : strerror(error_code);
}
- return desc ? desc : error_code < 0 ? NULL : strerror(error_code);
}