]> git.ozlabs.org Git - ccan/commitdiff
tcon: fix warning from gcc when tcon_check_ptr arg is constant.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 27 Aug 2024 04:12:02 +0000 (13:42 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 27 Aug 2024 04:12:02 +0000 (13:42 +0930)
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 <rusty@rustcorp.com.au>
ccan/tcon/tcon.h

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