net: Fix -Wmissing-braces #34090

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:251217-in6addr-compat changing 5 files +22 −7
  1. hebasto commented at 2:53 pm on December 17, 2025: member

    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:

     0$ uname -srv
     1SunOS 5.11 illumos-325e0fc8bb
     2$ clang --version
     3clang version 21.1.7 (https://github.com/OpenIndiana/oi-userland.git 36a81bf5e5d307d4e85893422600678d46328010)
     4Target: x86_64-pc-solaris2.11
     5Thread model: posix
     6InstalledDir: /usr/clang/21/bin
     7$ cmake -B build -DCMAKE_GENERATOR=Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_IPC=OFF -DAPPEND_CXXFLAGS='-Wno-unused-command-line-argument'
     8$ cmake --build build
     9[284/573] Building CXX object src/CMakeFiles/bitcoin_node.dir/net.cpp.o
    10/export/home/hebasto/dev/bitcoin/src/net.cpp:3309:42: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    11 3309 |         const CService ipv6_any{in6_addr(IN6ADDR_ANY_INIT), GetListenPort()}; // ::
    12      |                                          ^~~~~~~~~~~~~~~~
    13/usr/include/netinet/in.h:479:32: note: expanded from macro 'IN6ADDR_ANY_INIT'
    14  479 | #define IN6ADDR_ANY_INIT            {   0, 0, 0, 0,     \
    15      |                                         ^~~~~~~~~~~~~~~~~
    16  480 |                                         0, 0, 0, 0,     \
    17      |                                         ~~~~~~~~~~~~~~~~~
    18  481 |                                         0, 0, 0, 0,     \
    19      |                                         ~~~~~~~~~~~~~~~~~
    20  482 |                                         0, 0, 0, 0 }
    21      |                                         ~~~~~~~~~~
    221 warning generated.
    23[467/573] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/i2p_tests.cpp.o
    24/export/home/hebasto/dev/bitcoin/src/test/i2p_tests.cpp:116:34: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    25  116 |     const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), /*port=*/7656};
    26      |                                  ^~~~~~~~~~~~~~~~~~~~~
    27/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    28  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
    29      |                                         ^~~~~~~~~~~~~~~~~
    30  485 |                                         0, 0, 0, 0,     \
    31      |                                         ~~~~~~~~~~~~~~~~~
    32  486 |                                         0, 0, 0, 0,     \
    33      |                                         ~~~~~~~~~~~~~~~~~
    34  487 |                                         0, 0, 0, 0x1U }
    35      |                                         ~~~~~~~~~~~~~
    36/export/home/hebasto/dev/bitcoin/src/test/i2p_tests.cpp:159:38: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    37  159 |         const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), /*port=*/7656};
    38      |                                      ^~~~~~~~~~~~~~~~~~~~~
    39/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    40  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
    41      |                                         ^~~~~~~~~~~~~~~~~
    42  485 |                                         0, 0, 0, 0,     \
    43      |                                         ~~~~~~~~~~~~~~~~~
    44  486 |                                         0, 0, 0, 0,     \
    45      |                                         ~~~~~~~~~~~~~~~~~
    46  487 |                                         0, 0, 0, 0x1U }
    47      |                                         ~~~~~~~~~~~~~
    482 warnings generated.
    49[483/573] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/netbase_tests.cpp.o
    50/export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:505:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    51  505 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0 /* port */),
    52      |                                    ^~~~~~~~~~~~~~~~~~~~~
    53/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    54  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
    55      |                                         ^~~~~~~~~~~~~~~~~
    56  485 |                                         0, 0, 0, 0,     \
    57      |                                         ~~~~~~~~~~~~~~~~~
    58  486 |                                         0, 0, 0, 0,     \
    59      |                                         ~~~~~~~~~~~~~~~~~
    60  487 |                                         0, 0, 0, 0x1U }
    61      |                                         ~~~~~~~~~~~~~
    62/export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:510:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    63  510 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0x00f1 /* port */),
    64      |                                    ^~~~~~~~~~~~~~~~~~~~~
    65/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    66  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
    67      |                                         ^~~~~~~~~~~~~~~~~
    68  485 |                                         0, 0, 0, 0,     \
    69      |                                         ~~~~~~~~~~~~~~~~~
    70  486 |                                         0, 0, 0, 0,     \
    71      |                                         ~~~~~~~~~~~~~~~~~
    72  487 |                                         0, 0, 0, 0x1U }
    73      |                                         ~~~~~~~~~~~~~
    74/export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:515:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    75  515 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0xf1f2 /* port */),
    76      |                                    ^~~~~~~~~~~~~~~~~~~~~
    77/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    78  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
    79      |                                         ^~~~~~~~~~~~~~~~~
    80  485 |                                         0, 0, 0, 0,     \
    81      |                                         ~~~~~~~~~~~~~~~~~
    82  486 |                                         0, 0, 0, 0,     \
    83      |                                         ~~~~~~~~~~~~~~~~~
    84  487 |                                         0, 0, 0, 0x1U }
    85      |                                         ~~~~~~~~~~~~~
    863 warnings generated.
    87[573/573] Linking CXX executable bin/test_bitcoin
    

    The same issue is observed on Windows. For further details, see #31507.

  2. DrahtBot added the label P2P on Dec 17, 2025
  3. DrahtBot commented at 2:53 pm on December 17, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34090.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #31507 (build: Use clang-cl to build on Windows natively by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. hebasto force-pushed on Dec 17, 2025
  5. DrahtBot added the label CI failed on Dec 17, 2025
  6. fanquake commented at 3:10 pm on December 17, 2025: member

    https://github.com/bitcoin/bitcoin/actions/runs/20307057596/job/58327346295?pr=34090#step:11:495:

     0   net_processing.cpp
     1  netgroup.cpp
     2D:\a\bitcoin\bitcoin\src\net.cpp(3309,41): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'in6_addr' [D:\a\bitcoin\bitcoin\build\src\bitcoin_node.vcxproj]
     3      D:\a\bitcoin\bitcoin\src\net.cpp(3309,41):
     4      'in6_addr::in6_addr': no overloaded function could convert all the argument types
     5          C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared\in6addr.h(30,1):
     6          could be 'in6_addr::in6_addr(in6_addr &&)'
     7              D:\a\bitcoin\bitcoin\src\net.cpp(3309,41):
     8              'in6_addr::in6_addr(in6_addr &&)': cannot convert argument 1 from 'initializer list' to 'in6_addr &&'
     9                  D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
    10                  Reason: cannot convert from 'initializer list' to 'in6_addr'
    11                  D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
    12                  Invalid aggregate initialization
    13                      D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
    14                      'initializing': cannot convert from 'initializer list' to 'UCHAR'
    15                          D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
    16                          Too many braces around initializer for 'UCHAR'
    17          C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared\in6addr.h(30,1):
    18          or       'in6_addr::in6_addr(const in6_addr &)'
    19              D:\a\bitcoin\bitcoin\src\net.cpp(3309,41):
    20              'in6_addr::in6_addr(const in6_addr &)': cannot convert argument 1 from 'initializer list' to 'const in6_addr &'
    21                  D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
    22                  Reason: cannot convert from 'initializer list' to 'const in6_addr'
    23                  D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
    24                  Invalid aggregate initialization
    25                      D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
    26                      'initializing': cannot convert from 'initializer list' to 'UCHAR'
    27                          D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
    28                          Too many braces around initializer for 'UCHAR'
    29          D:\a\bitcoin\bitcoin\src\net.cpp(3309,41):
    30          while trying to match the argument list '(initializer list)'
    
  7. hebasto force-pushed on Dec 17, 2025
  8. hebasto force-pushed on Dec 17, 2025
  9. net: Fix `-Wmissing-braces` f46e3ec0f9
  10. hebasto force-pushed on Dec 17, 2025
  11. DrahtBot removed the label CI failed on Dec 17, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-19 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me