src: avoid unused variable 'error' warning

The variable is only used in DEBUG mode. Define it only in that case.

PR-URL: https://github.com/nodejs/node/pull/52886
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
Michaël Zasso 2024-05-10 09:50:20 +02:00 committed by GitHub
parent a923fed874
commit e03529ec27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -182,10 +182,13 @@ class Win32SymbolDebuggingContext final : public NativeSymbolDebuggingContext {
return NameAndDisplacement(pSymbol->Name, dwDisplacement);
} else {
// SymFromAddr failed
const DWORD error = GetLastError(); // "eat" the error anyway
#ifdef DEBUG
const DWORD error = GetLastError();
fprintf(stderr, "SymFromAddr returned error : %lu\n", error);
#endif
#else
// Consume the error anyway
USE(GetLastError());
#endif // DEBUG
}
// End MSDN code
@ -217,10 +220,13 @@ class Win32SymbolDebuggingContext final : public NativeSymbolDebuggingContext {
sym.line = line.LineNumber;
} else {
// SymGetLineFromAddr64 failed
const DWORD error = GetLastError(); // "eat" the error anyway
#ifdef DEBUG
const DWORD error = GetLastError();
fprintf(stderr, "SymGetLineFromAddr64 returned error : %lu\n", error);
#endif
#else
// Consume the error anyway
USE(GetLastError());
#endif // DEBUG
}
// End MSDN code
@ -240,10 +246,13 @@ class Win32SymbolDebuggingContext final : public NativeSymbolDebuggingContext {
return szUndName;
} else {
// UnDecorateSymbolName failed
const DWORD error = GetLastError(); // "eat" the error anyway
#ifdef DEBUG
const DWORD error = GetLastError();
fprintf(stderr, "UnDecorateSymbolName returned error %lu\n", error);
#endif
#else
// Consume the error anyway
USE(GetLastError());
#endif // DEBUG
}
return nullptr;
}