diff options
author | Mattias Andrée <maandree@kth.se> | 2021-03-05 23:30:24 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-03-05 23:30:24 +0100 |
commit | 80a78b91c2905fcacf0236d63a9f4e3d7e576d7e (patch) | |
tree | 305419312ba536e041be28bb271118e0ccf6956b /libgamma_strerror.c | |
parent | m (diff) | |
download | libgamma-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.c | 8 |
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); } |