From: Rusty Russell Date: Mon, 9 Jan 2023 02:06:22 +0000 (+1030) Subject: tcon: fix warning when it's used with NULL on some gcc versions. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=5c6a0ad7a9260c4cb02c707a0d813d17b23d9289 tcon: fix warning when it's used with NULL on some gcc versions. Seems to be happening with gcc 12.2.0-3ubuntu1: ``` lightningd/jsonrpc.c: In function ‘destroy_json_command’: lightningd/jsonrpc.c:1180:63: error: the comparison will always evaluate as ‘false’ for the address of ‘canary’ will never be NULL [-Werror=address] lightningd/jsonrpc.c:108:53: note: ‘canary’ declared here ``` Signed-off-by: Rusty Russell --- diff --git a/ccan/tcon/tcon.h b/ccan/tcon/tcon.h index e0f84b38..df3aac88 100644 --- a/ccan/tcon/tcon.h +++ b/ccan/tcon/tcon.h @@ -147,8 +147,7 @@ * It evaluates to @x so you can chain it. */ #define tcon_check_ptr(x, canary, expr) \ - (sizeof(&(x)->_tcon[0].canary == (expr)) ? (x) : (x)) - + (sizeof((expr) ? (expr) : &(x)->_tcon[0].canary) ? (x) : (x)) /** * tcon_type - the type within a container (or void *)