On Thu, 2023-11-09 at 16:24 +0100, Pablo Neira Ayuso wrote: > On Wed, Nov 08, 2023 at 07:24:24PM +0100, Thomas Haller wrote: > > > > +#define memory_allocation_check(cmd) \ > > + ({ \ > > + typeof((cmd)) _v = (cmd); \ > > + const void *const _v2 = _v; \ > > + \ > > + if (!_v2) \ > > please don't hide a if branch inside a macro. What is the reason for this rule? Is there a style guide somewhere? > > > + memory_allocation_error(); \ > > + _v; \ > > + }) It could be instead: static inline void *__memory_allocation_check(const char *file, unsigned line, const void *ptr) { if (!ptr) __memory_allocation_error(file, line); return (void*) ptr; } #define memory_allocation_check(cmd) \ ((typeof(cmd) __memory_allocation_check(__FILE__, __LINE__, (cmd)) Doesn't seem to make a difference either way. Thomas