summaryrefslogtreecommitdiff
path: root/src/libnm-std-aux
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-08-26 10:18:20 +0200
committerThomas Haller <thaller@redhat.com>2021-08-31 16:34:02 +0200
commit5e54cb5845a56ed9f422eada84c8f3ba897d1022 (patch)
treedfba61533111fdb5d46a259cebfa98af1d75b19b /src/libnm-std-aux
parent09ce76d85af35810dbc5b7d3d3f5f313bf624b8a (diff)
downloadNetworkManager-5e54cb5845a56ed9f422eada84c8f3ba897d1022.tar.gz
std-aux: let nm_assert() macros return a TRUE value
For most purposes, this makes no difference. But it allows to write something like: if ( ptr && nm_assert(check_ptr(ptr)) && other_check(ptr)) ...
Diffstat (limited to 'src/libnm-std-aux')
-rw-r--r--src/libnm-std-aux/nm-std-aux.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/libnm-std-aux/nm-std-aux.h b/src/libnm-std-aux/nm-std-aux.h
index 1101dbc48f..a23c40e680 100644
--- a/src/libnm-std-aux/nm-std-aux.h
+++ b/src/libnm-std-aux/nm-std-aux.h
@@ -175,38 +175,40 @@ typedef uint64_t _nm_bitwise nm_be64_t;
#if NM_MORE_ASSERTS
#define nm_assert(cond) \
- do { \
+ ({ \
_nm_assert_call(cond); \
- } while (0)
+ 1; \
+ })
#define nm_assert_se(cond) \
- do { \
+ ({ \
if (NM_LIKELY(cond)) { \
; \
} else { \
_nm_assert_call(0 && (cond)); \
} \
- } while (0)
+ 1; \
+ })
#define nm_assert_not_reached() \
- do { \
+ ({ \
_nm_assert_call_not_reached(); \
- } while (0)
+ 1; \
+ })
#else
#define nm_assert(cond) \
- do { \
+ ({ \
if (0) { \
if (cond) {} \
} \
- } while (0)
+ 1; \
+ })
#define nm_assert_se(cond) \
- do { \
+ ({ \
if (NM_LIKELY(cond)) { \
; \
} \
- } while (0)
-#define nm_assert_not_reached() \
- do { \
- ; \
- } while (0)
+ 1; \
+ })
+#define nm_assert_not_reached() ({ 1; })
#endif
/* This is similar nm_assert_not_reached(), but it's supposed to be used only during