mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 00:47:10 +09:00
macro-fundamental: allow to nest ASSERT_PTR
E.g.,
int job_frobnicate(Job *j) {
Unit *u = ASSERT_PTR(ASSERT_PTR(j)->unit);
...
}
This commit is contained in:
@@ -81,18 +81,13 @@
|
||||
#endif
|
||||
|
||||
/* This passes the argument through after (if asserts are enabled) checking that it is not null. */
|
||||
#define ASSERT_PTR(expr) \
|
||||
({ \
|
||||
typeof(expr) _expr_ = (expr); \
|
||||
assert(_expr_); \
|
||||
_expr_; \
|
||||
})
|
||||
|
||||
#define ASSERT_SE_PTR(expr) \
|
||||
({ \
|
||||
typeof(expr) _expr_ = (expr); \
|
||||
assert_se(_expr_); \
|
||||
_expr_; \
|
||||
#define ASSERT_PTR(expr) _ASSERT_PTR(expr, UNIQ_T(_expr_, UNIQ), assert)
|
||||
#define ASSERT_SE_PTR(expr) _ASSERT_PTR(expr, UNIQ_T(_expr_, UNIQ), assert_se)
|
||||
#define _ASSERT_PTR(expr, var, check) \
|
||||
({ \
|
||||
typeof(expr) var = (expr); \
|
||||
check(var); \
|
||||
var; \
|
||||
})
|
||||
|
||||
#define ASSERT_NONNEG(expr) \
|
||||
|
||||
Reference in New Issue
Block a user