From 28f5fcdbcad3c782004cef452d9df94134a85383 Mon Sep 17 00:00:00 2001 From: Krystie Date: Wed, 24 Jun 2026 19:03:14 -0700 Subject: [PATCH] init: forward-declare InitError / InitWarning for AppInit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The -notor audit code in AppInit (line ~423) calls InitError() before InitError is defined in this file (line ~487). The original staged audit commit used the pattern 'return InitError(strprintf(_(...)))' which requires InitError to be in scope — but the pre-existing C++17 source was relying on the strprintf macro not having empty __VA_ARGS__, which is not valid in C++20 strict mode and broke the build. Two related fixes in this commit: 1. Add forward declarations of InitError / InitWarning at the top of init.cpp so the AppInit body can use them before their definitions. 2. Drop the unnecessary strprintf(_(...)) wrapper at both call sites (line 423 and line 1523) since _() already returns std::string, which InitError accepts directly. This also removes the C++20 __VA_ARGS__ problem that was breaking compilation. The audit logic itself is unchanged — only the syntactic wrapper. --- src/init.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 1e72eec..ed16627 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -28,6 +28,11 @@ #include #include #include + +// Forward declaration: InitError / InitWarning are defined further down +// in this file but referenced by AppInit (line ~423) before the definition. +static bool InitError(const std::string& str); +static bool InitWarning(const std::string& str); #include #include #include @@ -420,12 +425,12 @@ bool AppInit(int argc, char* argv[]) // We refuse to proceed unless -recovery-mode=1 is ALSO set, even if // the flag was set in the config file rather than on the command line. if (mapArgs.count("-notor") && !GetBoolArg("-recovery-mode", false)) { - return InitError(strprintf(_( + return InitError(_( "-notor=1 found in triangles.conf or command line. Triangles is " "Tor-native; running without Tor is unsafe and produces silent " "clearnet forks (see 2026-06-23 DNS2 incident). If this is an " "explicit recovery operation, pass -recovery-mode=1 on the command " - "line (in addition to the config file setting) to acknowledge."))); + "line (in addition to the config file setting) to acknowledge.")); } if (mapArgs.count("-?") || mapArgs.count("--help")) @@ -1520,11 +1525,11 @@ bool AppInit2() // a new node) but requires an additional -recovery-mode=1 // confirmation flag so it cannot be flipped by accident. if (!GetBoolArg("-recovery-mode", false)) { - return InitError(strprintf(_( + return InitError(_( "-notor requires -recovery-mode=1 confirmation. Triangles is Tor-native; " "running without Tor is unsafe and produces silent clearnet forks. " "If you need clearnet mode for bootstrap recovery or diagnostics, " - "pass BOTH -notor=1 -recovery-mode=1 on the command line."))); + "pass BOTH -notor=1 -recovery-mode=1 on the command line.")); } printf("WARNING: Tor disabled via -notor AND -recovery-mode=1 set. " "Running in clearnet-only mode.\n");