mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-02 09:46:14 +00:00
f46e3ec0f9567a19ad9c111f264d395341327e4a net: Fix `-Wmissing-braces` (Hennadii Stepanov) Pull request description: On some non-POSIX platforms, Clang emits `-Wmissing-braces` warnings for the `IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` macros. For example, on OpenIndiana / illumos: ``` $ uname -srv SunOS 5.11 illumos-325e0fc8bb $ clang --version clang version 21.1.7 (https://github.com/OpenIndiana/oi-userland.git 36a81bf5e5d307d4e85893422600678d46328010) Target: x86_64-pc-solaris2.11 Thread model: posix InstalledDir: /usr/clang/21/bin $ cmake -B build -DCMAKE_GENERATOR=Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_IPC=OFF -DAPPEND_CXXFLAGS='-Wno-unused-command-line-argument' $ cmake --build build [284/573] Building CXX object src/CMakeFiles/bitcoin_node.dir/net.cpp.o /export/home/hebasto/dev/bitcoin/src/net.cpp:3309:42: warning: suggest braces around initialization of subobject [-Wmissing-braces] 3309 | const CService ipv6_any{in6_addr(IN6ADDR_ANY_INIT), GetListenPort()}; // :: | ^~~~~~~~~~~~~~~~ /usr/include/netinet/in.h:479:32: note: expanded from macro 'IN6ADDR_ANY_INIT' 479 | #define IN6ADDR_ANY_INIT { 0, 0, 0, 0, \ | ^~~~~~~~~~~~~~~~~ 480 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 481 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 482 | 0, 0, 0, 0 } | ~~~~~~~~~~ 1 warning generated. [467/573] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/i2p_tests.cpp.o /export/home/hebasto/dev/bitcoin/src/test/i2p_tests.cpp:116:34: warning: suggest braces around initialization of subobject [-Wmissing-braces] 116 | const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), /*port=*/7656}; | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT' 484 | #define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0, \ | ^~~~~~~~~~~~~~~~~ 485 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 486 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 487 | 0, 0, 0, 0x1U } | ~~~~~~~~~~~~~ /export/home/hebasto/dev/bitcoin/src/test/i2p_tests.cpp:159:38: warning: suggest braces around initialization of subobject [-Wmissing-braces] 159 | const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), /*port=*/7656}; | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT' 484 | #define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0, \ | ^~~~~~~~~~~~~~~~~ 485 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 486 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 487 | 0, 0, 0, 0x1U } | ~~~~~~~~~~~~~ 2 warnings generated. [483/573] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/netbase_tests.cpp.o /export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:505:36: warning: suggest braces around initialization of subobject [-Wmissing-braces] 505 | CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0 /* port */), | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT' 484 | #define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0, \ | ^~~~~~~~~~~~~~~~~ 485 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 486 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 487 | 0, 0, 0, 0x1U } | ~~~~~~~~~~~~~ /export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:510:36: warning: suggest braces around initialization of subobject [-Wmissing-braces] 510 | CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0x00f1 /* port */), | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT' 484 | #define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0, \ | ^~~~~~~~~~~~~~~~~ 485 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 486 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 487 | 0, 0, 0, 0x1U } | ~~~~~~~~~~~~~ /export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:515:36: warning: suggest braces around initialization of subobject [-Wmissing-braces] 515 | CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0xf1f2 /* port */), | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT' 484 | #define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0, \ | ^~~~~~~~~~~~~~~~~ 485 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 486 | 0, 0, 0, 0, \ | ~~~~~~~~~~~~~~~~~ 487 | 0, 0, 0, 0x1U } | ~~~~~~~~~~~~~ 3 warnings generated. [573/573] Linking CXX executable bin/test_bitcoin ``` The same issue is observed on Windows. For further details, see https://github.com/bitcoin/bitcoin/pull/31507. ACKs for top commit: bensig: ACK f46e3ec0f9567a19ad9c111f264d395341327e4a maflcko: review ACK f46e3ec0f9567a19ad9c111f264d395341327e4a 👭 vasild: ACK f46e3ec0f9567a19ad9c111f264d395341327e4a sedited: utACK f46e3ec0f9567a19ad9c111f264d395341327e4a Tree-SHA512: 9ad597d393ba04537b3aa728070ea7bbe1fc8796f6d8f3d90eb511242e5a61b0ab18123a6be3cca89aaa20ba7fb4dbe682c4d1c6bd3f6d883c459133e0c2861f