refactor: Use `NetworkErrorString` for macOS code in `netif.cpp`
What changed, and why it matters
This is a minor code cleanup in Bitcoin Core. It swaps one internal error-message helper for another that produces the exact same text on macOS and Linux, and removes an unused header include. There is no functional change and no security impact.
No security action needed. This is a non-functional refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit replaces two calls to SysErrorString(errno) with NetworkErrorString(errno) inside the macOS-specific APPLE branch of QueryDefaultGatewayImpl() in src/common/netif.cpp. The commit message and code confirm that NetworkErrorString() is identical to SysErrorString() on POSIX systems, so the produced log strings are unchanged. The only motivation is to remove #include
Changed components
src/common/netif.cppInspect captured patch +2 / −3
diff --git a/src/common/netif.cpp b/src/common/netif.cpp
index 8de3d819..a30046c7 100644
--- a/src/common/netif.cpp
+++ b/src/common/netif.cpp
@@ -10,7 +10,6 @@
#include <util/check.h>
#include <util/log.h>
#include <util/sock.h>
-#include <util/syserror.h>
#if defined(__linux__)
#include <linux/rtnetlink.h>
@@ -238,12 +237,12 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
// The size of the available data is determined by calling sysctl() with oldp=nullptr. See sysctl(3).
size_t l = 0;
if (sysctl(/*name=*/mib, /*namelen=*/sizeof(mib) / sizeof(int), /*oldp=*/nullptr, /*oldlenp=*/&l, /*newp=*/nullptr, /*newlen=*/0) < 0) {
- LogError("Could not get sysctl length of routing table: %s\n", SysErrorString(errno));
+ LogError("Could not get sysctl length of routing table: %s\n", NetworkErrorString(errno));
return std::nullopt;
}
std::vector<std::byte> buf(l);
if (sysctl(/*name=*/mib, /*namelen=*/sizeof(mib) / sizeof(int), /*oldp=*/buf.data(), /*oldlenp=*/&l, /*newp=*/nullptr, /*newlen=*/0) < 0) {
- LogError("Could not get sysctl data of routing table: %s\n", SysErrorString(errno));
+ LogError("Could not get sysctl data of routing table: %s\n", NetworkErrorString(errno));
return std::nullopt;
}
// Iterate over messages (each message is a routing table entry).
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.