Fix build: rename GetLastError to avoid Win32 collision, fix strprintf varargs
- Rename CTorProcess::GetLastError() and CTorEmbedded::GetLastError() to GetStartupError() so they don't shadow the Win32 GetLastError() API, which caused a std::string-to-DWORD conversion error on Windows. - Qualify the one Win32 call as ::GetLastError() for clarity. - Pass torError.c_str() to strprintf instead of std::string, fixing Clang's -Wnon-pod-varargs error on macOS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -1223,10 +1223,10 @@ bool AppInit2()
|
||||
fUseUPnP = false;
|
||||
#endif
|
||||
} else {
|
||||
std::string torError = CTorEmbedded::GetInstance()->GetLastError();
|
||||
std::string torError = CTorEmbedded::GetInstance()->GetStartupError();
|
||||
if (torError.empty())
|
||||
torError = "No detailed Tor startup error was recorded.";
|
||||
return InitError(strprintf(_("Tor failed to start. Triangles requires Tor to operate.\n\nDetails: %s"), torError));
|
||||
return InitError(strprintf(_("Tor failed to start. Triangles requires Tor to operate.\n\nDetails: %s"), torError.c_str()));
|
||||
}
|
||||
|
||||
// Initialize Tor V3 identity (Ed25519 keys, onion address)
|
||||
|
||||
@@ -248,7 +248,7 @@ bool CTorEmbedded::Start(int socks, int hsPort, bool enableHiddenService)
|
||||
torDataDir = (::GetDataDir() / "tor_data").string();
|
||||
running.store(StartTorProcess(torDataDir, socksPort, hiddenServicePort, hiddenServiceEnabled));
|
||||
if (!running.load()) {
|
||||
lastError = CTorProcess::GetInstance()->GetLastError();
|
||||
lastError = CTorProcess::GetInstance()->GetStartupError();
|
||||
}
|
||||
return running.load();
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ public:
|
||||
|
||||
// Get our .onion address (available after bootstrap)
|
||||
std::string GetOnionAddress() const { return onionHostname; }
|
||||
std::string GetLastError() const { return lastError; }
|
||||
void SetLastError(const std::string& value) { lastError = value; }
|
||||
std::string GetStartupError() const { return lastError; }
|
||||
void SetStartupError(const std::string& value) { lastError = value; }
|
||||
|
||||
// Get the hidden service port
|
||||
int GetHiddenServicePort() const { return hiddenServicePort; }
|
||||
|
||||
@@ -314,7 +314,7 @@ bool CTorProcess::Start(const std::string& dataDir, int socks, int hsPort, bool
|
||||
NULL, NULL,
|
||||
&si, &pi))
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
DWORD err = ::GetLastError();
|
||||
lastError = strprintf("CreateProcess failed for Tor binary '%s' with Windows error %lu", torBinaryPath.c_str(), err);
|
||||
printf("ERROR: Failed to start Tor process (error %lu)\n", err);
|
||||
return false;
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
// Get the Tor binary path (for diagnostics)
|
||||
std::string GetBinaryPath() const { return torBinaryPath; }
|
||||
std::string GetLastError() const { return lastError; }
|
||||
std::string GetStartupError() const { return lastError; }
|
||||
|
||||
// Singleton access
|
||||
static CTorProcess* GetInstance();
|
||||
|
||||
Reference in New Issue
Block a user