X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmacro.h;h=fd3762eed4aae50976bff45148966dbde4cb6764;hb=2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2;hp=54b641be2361593e9d2b57625e5450aea626817f;hpb=cabb78068899232c152f4585f19d023e373aa73d;p=elogind.git diff --git a/src/shared/macro.h b/src/shared/macro.h index 54b641be2..fd3762eed 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -153,10 +153,12 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { #define assert_cc(expr) struct UNIQUE(_assert_struct_) { char x[(expr) ? 0 : -1]; }; #endif -#define assert_return(expr, r) \ - do { \ - if (_unlikely_(!(expr))) \ - return (r); \ +#define assert_return(expr, r) \ + do { \ + if (_unlikely_(!(expr))) { \ + log_assert_failed_return(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \ + return (r); \ + } \ } while (false) #define PTR_TO_INT(p) ((int) ((intptr_t) (p))) @@ -285,16 +287,17 @@ do { \ #define SET_FLAG(v, flag, b) \ (v) = (b) ? ((v) | (flag)) : ((v) & ~(flag)) -#define IN_SET(x, ...) ({ \ - typeof(x) _x = (x); \ - unsigned _i; \ - bool _found = false; \ - for (_i = 0; _i < sizeof((typeof(_x)[]) { __VA_ARGS__ })/sizeof(typeof(_x)); _i++) \ - if (((typeof(_x)[]) { __VA_ARGS__ })[_i] == _x) { \ - _found = true; \ - break; \ - } \ - _found; \ +#define IN_SET(x, ...) \ + ({ \ + const typeof(x) _x = (x); \ + unsigned _i; \ + bool _found = false; \ + for (_i = 0; _i < sizeof((const typeof(_x)[]) { __VA_ARGS__ })/sizeof(const typeof(_x)); _i++) \ + if (((const typeof(_x)[]) { __VA_ARGS__ })[_i] == _x) { \ + _found = true; \ + break; \ + } \ + _found; \ })