summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeoff Norton <grompf@gmail.com>2015-02-08 10:12:12 -0800
committerGeoff Norton <grompf@gmail.com>2015-02-08 10:12:12 -0800
commit7b0a4ed9deda5bf9dbf3359fe2adeeb8238eb6b8 (patch)
tree8043879c2cc0600795ce6d5056516fada6bb59a0 /src
parenta01aa10e956f990486ed969696012a3d1a24888b (diff)
downloadcoreclr-7b0a4ed9deda5bf9dbf3359fe2adeeb8238eb6b8.tar.gz
coreclr-7b0a4ed9deda5bf9dbf3359fe2adeeb8238eb6b8.tar.bz2
coreclr-7b0a4ed9deda5bf9dbf3359fe2adeeb8238eb6b8.zip
Minor code structure refactoring as requested by @jkotas in PR #138
Diffstat (limited to 'src')
-rw-r--r--src/jit/compiler.cpp6
-rw-r--r--src/jit/error.cpp18
-rw-r--r--src/utilcode/stresslog.cpp9
3 files changed, 15 insertions, 18 deletions
diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp
index 2e1a6260a9..de8925d69c 100644
--- a/src/jit/compiler.cpp
+++ b/src/jit/compiler.cpp
@@ -92,20 +92,18 @@ unsigned jitCurSrcLine;
void Compiler::JitLogEE(unsigned level, const char* fmt, ...)
{
va_list args;
- va_start(args, fmt);
#ifndef CROSSGEN_COMPILE
if (verbose)
{
+ va_start(args, fmt);
logf_stdout(fmt, args);
- // logf_stdout can modify args so we need to reset it
va_end(args);
- va_start(args, fmt);
}
#endif
+ va_start(args, fmt);
vlogf(level, fmt, args);
-
va_end(args);
}
diff --git a/src/jit/error.cpp b/src/jit/error.cpp
index 348b190e4b..223afb1efb 100644
--- a/src/jit/error.cpp
+++ b/src/jit/error.cpp
@@ -380,7 +380,6 @@ void logf_stdout(const char* fmt, va_list args)
void logf(const char* fmt, ...)
{
va_list args;
- va_start(args, fmt);
static bool logToEEfailed = false;
//
// We remember when the EE failed to log, because vlogf()
@@ -389,19 +388,20 @@ void logf(const char* fmt, ...)
// If it fails to log an LL_INFO1000 message once
// it will always fail when logging an LL_INFO1000 message.
//
- if (logToEEfailed)
+ if (!logToEEfailed)
{
- logf_stdout(fmt, args);
+ va_start(args, fmt);
+ if (!vlogf(LL_INFO1000, fmt, args))
+ logToEEfailed = true;
+ va_end(args);
}
- else if (!vlogf(LL_INFO1000, fmt, args))
+
+ if (logToEEfailed)
{
- logToEEfailed = true;
-
- // The vlogf call may have modified args, so we need to reset it
- va_end(args);
+ // if the EE refuses to log it, we try to send it to stdout
va_start(args, fmt);
-
logf_stdout(fmt, args);
+ va_end(args);
}
#if 0 // Enable this only when you need it
else
diff --git a/src/utilcode/stresslog.cpp b/src/utilcode/stresslog.cpp
index a1581881aa..3d1720ccba 100644
--- a/src/utilcode/stresslog.cpp
+++ b/src/utilcode/stresslog.cpp
@@ -655,7 +655,6 @@ void StressLog::LogMsg (unsigned level, unsigned facility, int cArgs, const char
_ASSERTE ( cArgs >= 0 && cArgs <= 7 );
va_list Args;
- va_start(Args, format);
if(InlinedStressLogOn(facility, level))
{
@@ -667,20 +666,22 @@ void StressLog::LogMsg (unsigned level, unsigned facility, int cArgs, const char
if (msgs == 0)
return;
}
+ va_start(Args, format);
msgs->LogMsg (facility, cArgs, format, Args);
+ va_end(Args);
}
// Stress Log ETW feature available only on the desktop versions of the runtime
#if !defined(FEATURE_CORECLR)
// The previous LogMsg call could have modified the Args, so we need to reset it
- va_end(Args);
- va_start(Args, format);
if(InlinedETWLogOn(facility, level))
{
#define MAX_STRESSLOG_DATA_ETW_LENGTH 256
CHAR logMessage[MAX_STRESSLOG_DATA_ETW_LENGTH];
+ va_start(Args, format);
ULONG messageLength = (USHORT)_vsnprintf_s(logMessage, COUNTOF(logMessage), MAX_STRESSLOG_DATA_ETW_LENGTH-1, format, Args);
+ va_end(Args);
if(messageLength >= 0 &&
messageLength < MAX_STRESSLOG_DATA_ETW_LENGTH) // this condition has been added to make prefast happy
@@ -693,8 +694,6 @@ void StressLog::LogMsg (unsigned level, unsigned facility, int cArgs, const char
#undef MAX_STRESSLOG_DATA_ETW_LENGTH
}
#endif // !FEATURE_CORECLR
-
- va_end(Args);
#endif //!DACCESS_COMPILE
}