netif: fix compilation warning in QueryDefaultGatewayImpl() #34093

pull vasild wants to merge 1 commits into bitcoin:master from vasild:fix_nlmsg_ok_compilation_fbsd15 changing 1 files +5 −1
  1. vasild commented at 5:45 pm on December 17, 2025: contributor
    0src/common/netif.cpp:137:51: error: comparison of integers of different signs: 'int64_t' (aka 'long') and 'unsigned long' [-Werror,-Wsign-compare]
    1  137 |         for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, recv_result); hdr = NLMSG_NEXT(hdr, recv_result)) {
    2      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
    3/usr/include/netlink/netlink.h:220:31: note: expanded from macro 'NLMSG_OK'
    4  220 | #define NLMSG_OK(_hdr, _len)            NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN)
    5      |                                         ^                ~~~~  ~~~~~~~~~~~~
    6/usr/include/netlink/netlink.h:203:10: note: expanded from macro 'NL_ITEM_OK'
    7  203 |         ((_len) >= _hlen && _LEN_M(_ptr) >= _hlen && _LEN_M(_ptr) <= (_len))
    8      |           ~~~~  ^  ~~~~~
    91 error generated.
    

    Happens on FreeBSD 15.0, with the default compiler (Clang 19).

    On FreeBSD 14, /usr/include/netlink/netlink.h contains:

    0 #define NLMSG_HDRLEN                    ((int)sizeof(struct nlmsghdr))
    

    On FreeBSD 15, /usr/include/netlink/netlink.h contains:

    0 #define NLMSG_HDRLEN                    (sizeof(struct nlmsghdr))
    
  2. DrahtBot commented at 5:45 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/34093.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, hebasto

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  3. DrahtBot added the label CI failed on Dec 17, 2025
  4. DrahtBot commented at 7:36 pm on December 17, 2025: contributor

    🚧 At least one of the CI tasks failed. Task fuzzer,address,undefined,integer: https://github.com/bitcoin/bitcoin/actions/runs/20312066455/job/58346231710 LLM reason (✨ experimental): Compilation failed due to a -Werror sign-compare error in src/common/netif.cpp (NLMSG_OK usage).

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  5. vasild force-pushed on Dec 18, 2025
  6. vasild commented at 11:27 am on December 18, 2025: contributor

    I am not sure why there is no “comparison of integers of different signs” on Linux:

    0#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
    1                           (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
    2                           (nlh)->nlmsg_len <= (len))
    

    We pass int64_t for len. The first comparison checks it against (int)sizeof(..., but the 3rd comparison checks it against nlmsg_len which is __u32, so no matter what type is passed for len, one of the two comparisons is going to be of different sign, yet there is no warning :eyes: and if I pass unsigned type for len then I get a warning in the first comparison :fire:

  7. DrahtBot removed the label CI failed on Dec 18, 2025
  8. fanquake added the label Needs backport (30.x) on Dec 18, 2025
  9. maflcko commented at 3:35 pm on December 18, 2025: member

    I am not sure why there is no “comparison of integers of different signs” on Linux:

    0#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
    1                           (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
    2                           (nlh)->nlmsg_len <= (len))
    

    We pass int64_t for len. The first comparison checks it against (int)sizeof(..., but the 3rd comparison checks it against nlmsg_len which is __u32, so no matter what type is passed for len, one of the two comparisons is going to be of different sign, yet there is no warning 👀 and if I pass unsigned type for len then I get a warning in the first comparison 🔥

    I guess (int)sizeof(struct nlmsghdr) is a compile-time constant, so the compiler can see the value, or at least can see that it is never negative, so there is no issue?

  10. hebasto approved
  11. hebasto commented at 7:10 pm on December 18, 2025: member

    ACK be2a6248fbc6ade0c0cd734245138f83f3202266. See the following CI jobs:

  12. vasild commented at 5:57 am on December 19, 2025: contributor

    this PR on FreeBSD 15.0: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/20347897719

    The job is red but it compiles and then fails due to:

    feature_reindex_init.py | ✖ Failed | 1 s

    (offtopic) I have been annoyed by this failure, will try to look at it sometime soon.

    I guess (int)sizeof(struct nlmsghdr) is a compile-time constant, so the compiler can see the value, or at least can see that it is never negative, so there is no issue?

    Must be something more subtle because the following program:

     0#include <netlink/netlink.h>
     1#include <netlink/netlink_route.h>
     2
     3int main(int argc, char** argv)
     4{
     5    int64_t recv_result{static_cast<int64_t>(argc)};
     6
     7    int sizeof_struct_nlmsghdr{argc};
     8    uint32_t nlmsg_len{static_cast<uint32_t>(argc)};
     9
    10    if (recv_result >= sizeof_struct_nlmsghdr) { 
    11        return 0;
    12    } 
    13    if (nlmsg_len <= recv_result) { 
    14        return 0;
    15    } 
    16    return 0;
    17}
    

    does not emit a warning and none of the variables is a compile time constant. I would expect a warning for the second if which compares uint32_t and int64_t.

    I guess (int)sizeof(struct nlmsghdr) is a compile-time constant…

    That comparison is int64_t vs int - no warning should be emitted even if the compiler does not see that sizeof is compile time positive constant.

  13. maflcko commented at 6:06 am on December 19, 2025: member

    does not emit a warning and none of the variables is a compile time constant. I would expect a warning for the second if which compares uint32_t and int64_t.

    Why should it warn? uint32_t is of size 32, so it can perfectly fit into an int64_t and the compare can never behave unexpectedly?

  14. hebasto commented at 10:37 am on December 19, 2025: member

    this PR on FreeBSD 15.0: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/20347897719

    The job is red but it compiles and then fails due to:

    feature_reindex_init.py | ✖ Failed | 1 s

    (offtopic) I have been annoyed by this failure, will try to look at it sometime soon.

    Maybe #33128?

  15. vasild commented at 11:52 am on December 19, 2025: contributor

    I found this useful on the topic of integers comparison: This https://www.cppstories.com/2022/safe-int-cmp-cpp20/:

    • If both operands are signed or both are unsigned, the operand with lesser conversion rank is converted to the operand with the greater integer conversion rank.
    • Otherwise, if the unsigned operand’s conversion rank is greater or equal to the conversion rank of the signed operand, the signed operand is converted to the unsigned operand’s type.
    • Otherwise, if the signed operand’s type can represent all values of the unsigned operand, the unsigned operand is converted to the signed operand’s type.
    • Otherwise, both operands are converted to the unsigned counterpart of the signed operand’s type.

    The conversion rank above increases in order bool, signed char, short, int, long, long long (since C++11). The rank of any unsigned type is equal to the rank of the corresponding signed type.

    but:

     0(lldb) p (int8_t)-1 < (uint8_t)1
     1(bool) true
     2
     3(lldb) p (int16_t)-1 < (uint16_t)1
     4(bool) true
     5
     6(lldb) p (int32_t)-1 < (uint32_t)1
     7(bool) false
     8
     9(lldb) p (int64_t)-1 < (uint64_t)1
    10(bool) false
    

    :eyes:

  16. maflcko commented at 12:13 pm on December 19, 2025: member

    I found this useful on the topic of integers comparison: This https://www.cppstories.com/2022/safe-int-cmp-cpp20/:

    • If both operands are signed or both are unsigned, the operand with lesser conversion rank is converted to the operand with the greater integer conversion rank.
    • Otherwise, if the unsigned operand’s conversion rank is greater or equal to the conversion rank of the signed operand, the signed operand is converted to the unsigned operand’s type.
    • Otherwise, if the signed operand’s type can represent all values of the unsigned operand, the unsigned operand is converted to the signed operand’s type.
    • Otherwise, both operands are converted to the unsigned counterpart of the signed operand’s type.

    The conversion rank above increases in order bool, signed char, short, int, long, long long (since C++11). The rank of any unsigned type is equal to the rank of the corresponding signed type.

    but:

     0(lldb) p (int8_t)-1 < (uint8_t)1
     1(bool) true
     2
     3(lldb) p (int16_t)-1 < (uint16_t)1
     4(bool) true
     5
     6(lldb) p (int32_t)-1 < (uint32_t)1
     7(bool) false
     8
     9(lldb) p (int64_t)-1 < (uint64_t)1
    10(bool) false
    

    👀

    I haven’t read the blog post, but generally, cpprefernce is a better source about C++. It says https://en.cppreference.com/w/cpp/language/implicit_cast.html#Integral_promotion:

    prvalues of small integral types (such as char) and unscoped enumeration types may be converted to prvalues of larger integral types (such as int).

    So I think everything is expected here? Also, I don’t think any of the NLMSG macros deal with 16-bit ints, or lower.

  17. fanquake requested review from laanwj on Dec 19, 2025
  18. hebasto referenced this in commit 48a7c98287 on Dec 27, 2025
  19. luke-jr referenced this in commit 032391cb6e on Jan 13, 2026
  20. hebasto commented at 5:05 pm on January 28, 2026: member

    Happens on FreeBSD 15.0, with the default compiler (Clang 19).

    It’s also happening on FreeBSD 14.3 now, with the default Clang 19.1.7.

    UPDATE: #34093 (comment).

  21. maflcko commented at 5:18 pm on January 28, 2026: member
    Should probably derive the type to use via decltype and possibly some C++ metaprogramming
  22. vasild commented at 3:33 pm on February 2, 2026: contributor

    Happens on FreeBSD 15.0, with the default compiler (Clang 19).

    It’s also happening on FreeBSD 14.3 now, with the default Clang 19.1.7.

    Hmm, the latest 14 still has NLMSG_HDRLEN as int (unchanged):

    https://cgit.freebsd.org/src/tree/sys/netlink/netlink.h?h=stable/14#n216

    !?

  23. hebasto commented at 8:52 pm on February 2, 2026: member

    Happens on FreeBSD 15.0, with the default compiler (Clang 19).

    It’s also happening on FreeBSD 14.3 now, with the default Clang 19.1.7.

    Hmm, the latest 14 still has NLMSG_HDRLEN as int (unchanged):

    https://cgit.freebsd.org/src/tree/sys/netlink/netlink.h?h=stable/14#n216

    !?

    Upgraded compiler?

  24. vasild commented at 7:42 am on February 3, 2026: contributor

    Shouldn’t be compiler dependent. The original problem, currently in master is that it is comparing int64_t vs size_t on FreeBSD 15. On FreeBSD 14 it is ok because it is comparing int64_t vs int, based on netlink.h (not based on compiler version).

    What is the full error that you observe on FreeBSD 14?

  25. hebasto commented at 1:38 pm on February 3, 2026: member

    What is the full error that you observe on FreeBSD 14?

     0[98/835] Building CXX object src/CMakeFiles/bitcoin_common.dir/common/netif.cpp.o
     1/home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/src/common/netif.cpp:137:51: warning: comparison of integers of different signs: 'int64_t' (aka 'long') and 'unsigned long' [-Wsign-compare]
     2  137 |         for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, recv_result); hdr = NLMSG_NEXT(hdr, recv_result)) {
     3      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
     4/usr/include/netlink/netlink.h:220:31: note: expanded from macro 'NLMSG_OK'
     5  220 | #define NLMSG_OK(_hdr, _len)            NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN)
     6      |                                         ^                ~~~~  ~~~~~~~~~~~~
     7/usr/include/netlink/netlink.h:203:10: note: expanded from macro 'NL_ITEM_OK'
     8  203 |         ((_len) >= _hlen && _LEN_M(_ptr) >= _hlen && _LEN_M(_ptr) <= (_len))
     9      |           ~~~~  ^  ~~~~~
    101 warning generated.
    

    More logs are available here: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/21632105860.

    UPDATE. Disregard this comment as it seems the GHA workflow I mentioned is broken.

  26. hebasto commented at 2:25 pm on February 3, 2026: member

    Happens on FreeBSD 15.0, with the default compiler (Clang 19).

    It’s also happening on FreeBSD 14.3 now, with the default Clang 19.1.7.

    This comment is incorrect. I used a log from the broken GHA workflow. My apologies.

  27. fanquake commented at 9:50 am on February 20, 2026: member

    Should probably derive the type to use via decltype and possibly some C++ metaprogramming @vasild did you see this comment?

  28. vasild commented at 2:37 pm on February 23, 2026: contributor

    Should probably derive the type to use via decltype and possibly some C++ metaprogramming

    @vasild did you see this comment?

    Yes. I didn’t act on it because I think it is in reply to an earlier comment “It’s also happening on FreeBSD 14.3 now” and @maflcko is suggesting how to resolve that. Later on it turned out that this PR is fine on FreeBSD 14, so nothing needs to be addressed. @maflcko, right?

  29. maflcko commented at 2:57 pm on February 23, 2026: member
    It seems likely that the other *BSD will follow, no? It just doesn’t seem a good use of time to maintain a hard-coded list of “user agents”. It seems better to just make this feature-based and auto-detecting.
  30. vasild commented at 7:49 am on February 24, 2026: contributor

    It seems better to just make this feature-based and auto-detecting.

    Do you have a patch?

  31. maflcko commented at 8:28 am on February 25, 2026: member

    It seems better to just make this feature-based and auto-detecting.

    Do you have a patch?

    I was thinking using recv_result_t = std::conditional_t<std::is_signed_v<decltype(NLMSG_HDRLEN)>, ...

    However, I wonder why all of this is needed. Why not just simply:

    0        for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, static_cast<uint32_t>(recv_result)); hdr = NLMSG_NEXT(hdr, recv_result)) {
    

    See #34093 (comment)

  32. vasild commented at 10:11 am on February 25, 2026: contributor

    From the OP, netlink.h is comparing what we pass it to:

    • int on FreeBSD 14 and to
    • size_t on FreeBSD 15,

    so if we pass it signed or unsigned it will be upset either way on one of FreeBSD 14 or 15, no?

  33. maflcko commented at 10:18 am on February 25, 2026: member

    No, it should work fine. See the linked comment (my first reply on this thread). I’ve also tested it with clang version 20.1.8.

    If not, can you please share the error message you are seeing, or a minimal reproducer that can be put into godbolt?

  34. vasild commented at 1:48 pm on February 25, 2026: contributor

    If not, can you please share the error message you are seeing, or a minimal reproducer that can be put into godbolt?

    Changed line 137 in src/common/netif.cpp to, like suggested:

    0        for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, static_cast<uint32_t>(recv_result)); hdr = NLMSG_NEXT(hdr, recv_result)) {
    
     0$ head -2 /etc/os-release
     1NAME=FreeBSD
     2VERSION="14.3-STABLE"
     3
     4$ /usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -I/wrkdirs/usr/ports/net-p2p/bitcoin-daemon/work/.build/src -I/wrkdirs/usr/ports/net-p2p/bitcoin-daemon/work/bitcoin-30.2/src -I/wrkdirs/usr/ports/net-p2p/bitcoin-daemon/work/bitcoin-30.2/src/univalue/include -I/wrkdirs/usr/ports/net-p2p/bitcoin-daemon/work/bitcoin-30.2/src/secp256k1/include -isystem /usr/local/include -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing   -std=c++20 -fPIC -fdebug-prefix-map=/wrkdirs/usr/ports/net-p2p/bitcoin-daemon/work/bitcoin-30.2/src=. -fmacro-prefix-map=/wrkdirs/usr/ports/net-p2p/bitcoin-daemon/work/bitcoin-30.2/src=. -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -Wsign-compare -fstack-protector-all -fcf-protection=full -fstack-clash-protection -pthread -Wall -Wextra -Wgnu -Wformat -Wformat-security -Wvla -Wshadow-field -Wthread-safety -Wloop-analysis -Wredundant-decls -Wunused-member-function -Wdate-time -Wconditional-uninitialized -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wdocumentation -Wself-assign -Wundef -Wno-unused-parameter -MD -MT src/CMakeFiles/bitcoin_common.dir/common/netif.cpp.o -MF src/CMakeFiles/bitcoin_common.dir/common/netif.cpp.o.d -o src/CMakeFiles/bitcoin_common.dir/common/netif.cpp.o -c /wrkdirs/usr/ports/net-p2p/bitcoin-daemon/work/bitcoin-30.2/src/common/netif.cpp
     5/wrkdirs/usr/ports/net-p2p/bitcoin-daemon/work/bitcoin-30.2/src/common/netif.cpp:137:51: warning: comparison of integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') [-Wsign-compare]
     6  137 |         for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, static_cast<uint32_t>(recv_result)); hdr = NLMSG_NEXT(hdr, recv_result)) {
     7      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     8/usr/include/netlink/netlink.h:222:31: note: expanded from macro 'NLMSG_OK'
     9  222 | #define NLMSG_OK(_hdr, _len)            NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN)
    10      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    11/usr/include/netlink/netlink.h:206:60: note: expanded from macro 'NL_ITEM_OK'
    12  206 |         ((_len) >= _hlen && _LEN_M(_ptr) >= _hlen && _LEN_M(_ptr) <= (_len))
    13      |                                                      ~~~~~~~~~~~~ ^   ~~~~
    141 warning generated.
    
  35. maflcko commented at 2:02 pm on February 25, 2026: member

    Ok, but that looks like a different path. Can you upload the full netlink.h for the freebsd versions?

    Is there a rationale why they even changed this in one place, but not the others? I think someone should ask upstream to revert this, because I fail to see how this makes sense.

  36. vasild commented at 2:28 pm on February 25, 2026: contributor

    https://github.com/freebsd/freebsd-src/blob/stable/14/sys/netlink/netlink.h https://github.com/freebsd/freebsd-src/blob/stable/15/sys/netlink/netlink.h https://github.com/freebsd/freebsd-src/commit/c7919fb92d201ab1d5bd3ab0c18cbcea961ef761 (makes sense to me)

    Maybe this is better:

    0#ifdef __FreeBSD__
    1        using recv_result_t = decltype(NLMSG_HDRLEN);
    2#else   
    3        using recv_result_t = int64_t;
    4#endif  
    5        for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, static_cast<recv_result_t>(recv_result)); hdr = NLMSG_NEXT(hdr, recv_result)) {
    

    it does not have the FreeBSD version in it and netif.cpp already contains some checks whether __FreeBSD__ is defined.

  37. maflcko commented at 5:59 pm on February 25, 2026: member

    Oh, I see. Your new error refers to the old freebsd 14 header, which has an int cast before every ((int)(_hdr)->nlmsg_len) as well. In that case uint32_t will work for Linux+FreeBSD15, but not 14.

    So I guess there are three options that should work and that avoid hard-coding the freebsd version number:

    0using recv_result_t = std::conditional_t<std::is_signed_v<decltype(NLMSG_HDRLEN)>, int64_t, uint64_t>;
    1using recv_result_t = std::conditional_t<std::is_signed_v<decltype(NLMSG_HDRLEN)>, int64_t, uint32_t>;
    2using recv_result_t = std::conditional_t<std::is_signed_v<decltype(NLMSG_HDRLEN)>, int64_t, decltype(NLMSG_HDRLEN)>;
    

    I guess it doesn’t really matter, as long as it compiles :man_shrugging:

    edit: To clarify a plain NLMSG_OK(hdr, static_cast<decltype(NLMSG_HDRLEN)>(recv_result)) does not work on Linux.

  38. vasild commented at 7:48 am on February 26, 2026: contributor

    To summarize - the current PR produces no warning on Linux, FreeBSD 14 and 15. It is not about the compiler, but about the contents of /usr/include/netlink/netlink.h. The below patch is fine as well:

    0-        for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, recv_result); hdr = NLMSG_NEXT(hdr, recv_result)) {
    1+        using recv_result_t = std::conditional_t<std::is_signed_v<decltype(NLMSG_HDRLEN)>, int64_t, decltype(NLMSG_HDRLEN)>;
    2+
    3+        for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, static_cast<recv_result_t>(recv_result)); hdr = NLMSG_NEXT(hdr, recv_result)) {
    

    Better? @hebasto?

  39. hebasto commented at 5:37 pm on February 26, 2026: member

    To summarize - the current PR produces no warning on Linux, FreeBSD 14 and 15. It is not about the compiler, but about the contents of /usr/include/netlink/netlink.h. The below patch is fine as well:

    0-        for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, recv_result); hdr = NLMSG_NEXT(hdr, recv_result)) {
    1+        using recv_result_t = std::conditional_t<std::is_signed_v<decltype(NLMSG_HDRLEN)>, int64_t, decltype(NLMSG_HDRLEN)>;
    2+
    3+        for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, static_cast<recv_result_t>(recv_result)); hdr = NLMSG_NEXT(hdr, recv_result)) {
    

    Better? @hebasto?

    It looks great, and it works great.

    Mind also #include <type_traits> for that diff?

  40. netif: fix compilation warning in QueryDefaultGatewayImpl()
    ```
    src/common/netif.cpp:137:51: error: comparison of integers of different signs: 'int64_t' (aka 'long') and 'unsigned long' [-Werror,-Wsign-compare]
      137 |         for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, recv_result); hdr = NLMSG_NEXT(hdr, recv_result)) {
          |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/netlink/netlink.h:220:31: note: expanded from macro 'NLMSG_OK'
      220 | #define NLMSG_OK(_hdr, _len)            NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN)
          |                                         ^                ~~~~  ~~~~~~~~~~~~
    /usr/include/netlink/netlink.h:203:10: note: expanded from macro 'NL_ITEM_OK'
      203 |         ((_len) >= _hlen && _LEN_M(_ptr) >= _hlen && _LEN_M(_ptr) <= (_len))
          |           ~~~~  ^  ~~~~~
    1 error generated.
    ```
    
    Happens on FreeBSD 15.0, with the default compiler (Clang 19).
    
    On FreeBSD 14, `/usr/include/netlink/netlink.h` contains:
    ```
     #define NLMSG_HDRLEN                    ((int)sizeof(struct nlmsghdr))
    ```
    
    On FreeBSD 15, `/usr/include/netlink/netlink.h` contains:
    ```
     #define NLMSG_HDRLEN                    (sizeof(struct nlmsghdr))
    ```
    
    Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
    c1361fc42d
  41. vasild force-pushed on Feb 27, 2026
  42. vasild commented at 4:51 am on February 27, 2026: contributor
    Done, thanks!
  43. maflcko commented at 7:07 am on February 27, 2026: member
    lgtm ACK c1361fc42dd60606fcd6273cede1083cd88866a2
  44. DrahtBot requested review from hebasto on Feb 27, 2026
  45. hebasto approved
  46. hebasto commented at 9:20 am on February 27, 2026: member
    ACK c1361fc42dd60606fcd6273cede1083cd88866a2.
  47. fanquake merged this on Feb 27, 2026
  48. fanquake closed this on Feb 27, 2026

  49. fanquake referenced this in commit a09b4cc12a on Feb 27, 2026
  50. fanquake removed the label Needs backport (30.x) on Feb 27, 2026
  51. fanquake commented at 12:05 pm on February 27, 2026: member
    Backported to 30.x in #34689.
  52. fanquake added the label Needs backport (29.x) on Feb 27, 2026
  53. fanquake commented at 12:06 pm on February 27, 2026: member
    Looks like this needs to go to 29.x as well.
  54. fanquake removed the label Needs backport (29.x) on Feb 27, 2026
  55. fanquake commented at 12:12 pm on February 27, 2026: member
    Backported to 29.x in #34680.
  56. fanquake referenced this in commit 490cd874a4 on Feb 27, 2026
  57. maflcko commented at 12:37 pm on February 27, 2026: member
    Just for reference, I tried the simple single cast to u32 in https://github.com/maflcko/bitcoin-core-nightly-alt-pr/pull/2 and it looks like FreeBSD 14 is the only disto with the “bug” (at least in the test matrix). So if anyone stumbles upon this in the future when FreeBSD 14 is EOL, this can be replaced by just static_cast<uint32_t>(recv_result).
  58. vasild deleted the branch on Mar 2, 2026

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: 2026-03-12 21:13 UTC

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