From: Rusty Russell Date: Tue, 27 Aug 2024 04:12:02 +0000 (+0930) Subject: tcon: fix warning from gcc when tcon_check_ptr arg is constant. X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=624dbca5fe08119b2c339929afaf9351f70bac26;p=ccan tcon: fix warning from gcc when tcon_check_ptr arg is constant. e.g. `&msg`: ``` src/nostrdb.c: In function ‘ndb_ingester_queue_event’: ccan/ccan/tcon/tcon.h:150:24: error: the address of ‘msg’ will always evaluate as ‘true’ [-Werror=address] 150 | (sizeof((expr) ? (expr) : &(x)->_tcon[0].canary) ? (x) : (x)) | ^ ccan/ccan/tcon/tcon.h:116:30: note: in definition of macro ‘tcon_unwrap’ 116 | #define tcon_unwrap(ptr) (&((ptr)->_base)) | ^~~ src/threadpool.h:91:42: note: in expansion of macro ‘tcon_check_ptr’ 91 | threadpool_dispatch_(tcon_unwrap(tcon_check_ptr((tp), tp_canary, (msg))), (msg)) | ^~~~~~~~~~~~~~ src/nostrdb.c:4114:16: note: in expansion of macro ‘threadpool_dispatch’ 4114 | return threadpool_dispatch(&ingester->tp, &msg); ``` Signed-off-by: Rusty Russell --- diff --git a/ccan/tcon/tcon.h b/ccan/tcon/tcon.h index df3aac88..35d83e19 100644 --- a/ccan/tcon/tcon.h +++ b/ccan/tcon/tcon.h @@ -147,7 +147,7 @@ * It evaluates to @x so you can chain it. */ #define tcon_check_ptr(x, canary, expr) \ - (sizeof((expr) ? (expr) : &(x)->_tcon[0].canary) ? (x) : (x)) + (sizeof(0 ? (expr) : &(x)->_tcon[0].canary) ? (x) : (x)) /** * tcon_type - the type within a container (or void *)