From eccb04a321acd698dc221b826fe030cb16edd62b Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Mon, 6 Jul 2026 12:10:33 +0100 Subject: [PATCH] refactor: Use `NetworkErrorString` for macOS code in `netif.cpp` Although these `sysctl` calls report generic system errors rather than network errors, `NetworkErrorString()` is identical to `SysErrorString()` on POSIX systems, so this does not change behavior. It allows removing `#include `, which was only needed by `__APPLE__` code and would otherwise require an `#ifdef` guard to silence an IWYU unused-include warning on other platforms. --- src/common/netif.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common/netif.cpp b/src/common/netif.cpp index 8de3d81968a..a30046c7cdc 100644 --- a/src/common/netif.cpp +++ b/src/common/netif.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #if defined(__linux__) #include @@ -238,12 +237,12 @@ std::optional 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 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).