]> git.ozlabs.org Git - ccan/commitdiff
tcon: fix overzealous gcc 12.2.0 warning.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 9 Jan 2023 02:09:22 +0000 (12:39 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 16 Mar 2023 23:22:47 +0000 (09:52 +1030)
At least with -fsanitize=address -fno-sanitize-recover=address -fsanitize=undefined -fno-sanitize-recover=undefined:

```
/home/rusty/devel/cvs/ccan/ccan/tcon/test/compile_fail-container1.c:Compile gave warnings without -DFAIL:
In file included from /home/rusty/devel/cvs/ccan/ccan/tcon/test/compile_fail-container1.c:3:
/home/rusty/devel/cvs/ccan/ccan/tcon/tcon.h: In function ‘main’:
/home/rusty/devel/cvs/ccan/ccan/tcon/tcon.h:332:25: warning: ‘innerp’ may be used uninitialized [-Wmaybe-uninitialized]
  332 |                 canary, tcon_container_of_((member_ptr),                \
      |                         ^~~~~~~~~~~~~~~~~~
/home/rusty/devel/cvs/ccan/ccan/tcon/tcon.h:335:21: note: by argument 1 of type ‘const void *’ to ‘tcon_container_of_’ declared here
  335 | static inline void *tcon_container_of_(const void *member_ptr, size_t offset)
      |                     ^~~~~~~~~~~~~~~~~~
/home/rusty/devel/cvs/ccan/ccan/tcon/test/compile_fail-container1.c:28:22: note: ‘ovar’ declared here
   28 |         struct outer ovar;
      |                      ^~~~

tcon: Total score: 33/41 FAIL!
```

ccan/tcon/test/compile_fail-container1.c
ccan/tcon/test/compile_fail-container1w.c
ccan/tcon/test/compile_fail-container3.c
ccan/tcon/test/compile_fail-container3w.c

index 44645a7ec6d417875ceed8910915efea3a0d2193..ed1d3e206acd97eee8cf46b69e8018a5a87096e4 100644 (file)
@@ -25,7 +25,7 @@ struct info_tcon {
 int main(void)
 {
        struct info_tcon info;
 int main(void)
 {
        struct info_tcon info;
-       struct outer ovar;
+       struct outer ovar = { 0, { 0 } };
 #ifdef FAIL
 #if !HAVE_TYPEOF
 #error We cannot detect type problems without HAVE_TYPEOF
 #ifdef FAIL
 #if !HAVE_TYPEOF
 #error We cannot detect type problems without HAVE_TYPEOF
index 19ba5bdcc915d22851009a630b4bda32dd85f242..a03f6514e1793b0dce08c45cc23cd34c7078d01c 100644 (file)
@@ -21,7 +21,7 @@ int main(void)
 {
        TCON_WRAP(struct info_base,
                  TCON_CONTAINER(concan, struct outer, inner)) info;
 {
        TCON_WRAP(struct info_base,
                  TCON_CONTAINER(concan, struct outer, inner)) info;
-       struct outer ovar;
+       struct outer ovar = { 0, { 0 } };
 #ifdef FAIL
 #if !HAVE_TYPEOF
 #error We cannot detect type problems without HAVE_TYPEOF
 #ifdef FAIL
 #if !HAVE_TYPEOF
 #error We cannot detect type problems without HAVE_TYPEOF
index 9185225a9361903e25e86ce616e31da0e502e577..dfdfdba9a3412ef692311762b9cdfdd54d01c4e5 100644 (file)
@@ -25,7 +25,7 @@ struct info_tcon {
 int main(void)
 {
        struct info_tcon info;
 int main(void)
 {
        struct info_tcon info;
-       struct outer ovar;
+       struct outer ovar = { 0, { 0 } };
 #ifdef FAIL
 #if !HAVE_TYPEOF
 #error We cannot detect type problems without HAVE_TYPEOF
 #ifdef FAIL
 #if !HAVE_TYPEOF
 #error We cannot detect type problems without HAVE_TYPEOF
index 958e5c8b3dca47c67c1f23aa25fe9fc29e759e90..a56e510f1e2bb86f326b917ad61bc17c839281b2 100644 (file)
@@ -21,7 +21,7 @@ int main(void)
 {
        TCON_WRAP(struct info_base,
                  TCON_CONTAINER(concan, struct outer, inner)) info;
 {
        TCON_WRAP(struct info_base,
                  TCON_CONTAINER(concan, struct outer, inner)) info;
-       struct outer ovar;
+       struct outer ovar = { 0, { 0 } };
 #ifdef FAIL
 #if !HAVE_TYPEOF
 #error We cannot detect type problems without HAVE_TYPEOF
 #ifdef FAIL
 #if !HAVE_TYPEOF
 #error We cannot detect type problems without HAVE_TYPEOF