diff options
author | Mattias Andrée <maandree@kth.se> | 2020-05-11 19:42:44 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2020-05-11 19:42:44 +0200 |
commit | 51fbe0753b241c3880147a9a89244f16fbffedd7 (patch) | |
tree | 15ad9aab01f5b14d990cfe17d3870af7b568703e /common.h | |
parent | Documentation, use of liberror, and implement libaxl_deallocate_id (diff) | |
download | libaxl-51fbe0753b241c3880147a9a89244f16fbffedd7.tar.gz libaxl-51fbe0753b241c3880147a9a89244f16fbffedd7.tar.bz2 libaxl-51fbe0753b241c3880147a9a89244f16fbffedd7.tar.xz |
Fix error checking
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -35,17 +35,17 @@ # define __checked_ptr(X, _FUN) X # define __checked_ssize_t(X, _FUN) X # else -# define DEFINE_CHECKED(TYPE, NAME)\ +# define DEFINE_CHECKED(TYPE, NAME, ERR_IF)\ static inline TYPE\ NAME(TYPE ret, const char *func)\ {\ - if (!ret)\ + if (ERR_IF)\ liberror_set_error_errno(strerror(errno), func, errno);\ return ret;\ } -DEFINE_CHECKED(int, __checked_int) -DEFINE_CHECKED(void *, __checked_ptr) -DEFINE_CHECKED(ssize_t, __checked_ssize_t) +DEFINE_CHECKED(int, __checked_int, ret < 0) +DEFINE_CHECKED(void *, __checked_ptr, !ret) +DEFINE_CHECKED(ssize_t, __checked_ssize_t, ret < 0) # endif # define liberror_snprintf(...) __checked_int(snprintf(__VA_ARGS__), "snprintf") # define liberror_close(FD) __checked_int(close(FD), "close") |