From: Rusty Russell Date: Mon, 9 Jan 2023 02:09:22 +0000 (+1030) Subject: tcon: fix overzealous gcc 12.2.0 warning. X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=e62e48b9d841dd7bac1955df177c2089eb4719b7 tcon: fix overzealous gcc 12.2.0 warning. 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! ``` --- diff --git a/ccan/tcon/test/compile_fail-container1.c b/ccan/tcon/test/compile_fail-container1.c index 44645a7e..ed1d3e20 100644 --- a/ccan/tcon/test/compile_fail-container1.c +++ b/ccan/tcon/test/compile_fail-container1.c @@ -25,7 +25,7 @@ struct info_tcon { 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 diff --git a/ccan/tcon/test/compile_fail-container1w.c b/ccan/tcon/test/compile_fail-container1w.c index 19ba5bdc..a03f6514 100644 --- a/ccan/tcon/test/compile_fail-container1w.c +++ b/ccan/tcon/test/compile_fail-container1w.c @@ -21,7 +21,7 @@ int main(void) { 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 diff --git a/ccan/tcon/test/compile_fail-container3.c b/ccan/tcon/test/compile_fail-container3.c index 9185225a..dfdfdba9 100644 --- a/ccan/tcon/test/compile_fail-container3.c +++ b/ccan/tcon/test/compile_fail-container3.c @@ -25,7 +25,7 @@ struct info_tcon { 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 diff --git a/ccan/tcon/test/compile_fail-container3w.c b/ccan/tcon/test/compile_fail-container3w.c index 958e5c8b..a56e510f 100644 --- a/ccan/tcon/test/compile_fail-container3w.c +++ b/ccan/tcon/test/compile_fail-container3w.c @@ -21,7 +21,7 @@ int main(void) { 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