From: Arran Cudbard-Bell Date: Thu, 12 Jan 2023 19:43:16 +0000 (-0600) Subject: Another attempt at accepting NULL macro args X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2a349ed374f6a2d6ca53f7be9ac11047d55f46e;p=thirdparty%2Ffreeradius-server.git Another attempt at accepting NULL macro args --- diff --git a/src/lib/util/atexit.h b/src/lib/util/atexit.h index 0ca76790c1a..1b1bd4fdc4a 100644 --- a/src/lib/util/atexit.h +++ b/src/lib/util/atexit.h @@ -91,6 +91,7 @@ static inline int _fr_atexit_global_once_funcs(fr_atexit_t init_func, fr_atexit_ } static inline void fr_atexit_noop(void) {} +static inline void fr_atexit_result(int *ret, int val) { *ret = val; } /** Setup pair of global init/free functions * @@ -122,14 +123,14 @@ static inline void fr_atexit_noop(void) {} pthread_mutex_lock(&_init_mutex); \ if (!atomic_load(&_init_done)) { \ if (_fr_atexit_global_once_funcs(_init, _free, _our_uctx) < 0) { \ - _Generic((_res), int : _res = -1, default: fr_atexit_noop()); \ + _Generic((_res), int : fr_atexit_result((int *)&(_res), -1), default: fr_atexit_noop()); \ pthread_mutex_unlock(&_init_mutex); \ } \ atomic_store(&_init_done, true); \ } \ pthread_mutex_unlock(&_init_mutex); \ } \ - _Generic((_res), int : _res = 0, default: fr_atexit_noop()); \ + _Generic((_res), int : fr_atexit_result((int *)&(_res), 0), default: fr_atexit_noop()); \ } /** Set a destructor for thread local storage to free the memory on thread exit *