]> git.ozlabs.org Git - ccan/commitdiff
tcon: fix warning when it's used with NULL on some gcc versions.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 9 Jan 2023 02:06:22 +0000 (12:36 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 27 Apr 2023 01:14:40 +0000 (10:44 +0930)
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 <rusty@rustcorp.com.au>
ccan/tcon/tcon.h

index e0f84b383976c4d106e6d9fe3ee9043c449d1ed8..df3aac88b785a4acc241e125a9c377766a55272d 100644 (file)
  * 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 *)