From 366e641139130833a7354d9f2f96ce72633b1053 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Wed, 17 Jun 2015 01:15:09 +0200 Subject: sd-event: make errors on EPOLL_CTL_DEL pseudo-fatal If we call EPOLL_CTL_DEL, we *REALLY* expect the file-descriptor to be present in that given epoll-set. We actually track such state via our s->io.registered flag, so it better be true. Make sure if that's not true, we treat it similar to assert_return() (ie., print a loud warning). --- src/basic/macro.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/basic/macro.h') diff --git a/src/basic/macro.h b/src/basic/macro.h index cc1c9e73c0..5fa17ed208 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -248,18 +248,19 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { REENABLE_WARNING #endif +#define assert_log(expr) ((_likely_(expr)) \ + ? (true) \ + : (log_assert_failed_return(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__), false)) + #define assert_return(expr, r) \ do { \ - if (_unlikely_(!(expr))) { \ - log_assert_failed_return(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \ + if (!assert_log(expr)) \ return (r); \ - } \ } while (false) #define assert_return_errno(expr, r, err) \ do { \ - if (_unlikely_(!(expr))) { \ - log_assert_failed_return(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \ + if (!assert_log(expr)) { \ errno = err; \ return (r); \ } \ -- cgit v1.2.3-54-g00ecf