aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-05-11 19:42:44 +0200
committerMattias Andrée <maandree@kth.se>2020-05-11 19:42:44 +0200
commit51fbe0753b241c3880147a9a89244f16fbffedd7 (patch)
tree15ad9aab01f5b14d990cfe17d3870af7b568703e /common.h
parentDocumentation, use of liberror, and implement libaxl_deallocate_id (diff)
downloadlibaxl-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.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/common.h b/common.h
index 3d76d23..c54d000 100644
--- a/common.h
+++ b/common.h
@@ -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")