Skip to content

Commit fbc2e47

Browse files
Address static analysis issues
1 parent a091885 commit fbc2e47

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Tests/CommandLineTests.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ void QpcTimeTest(wchar_t const* qpcTimeArg)
8888
auto idxProcessID = csv.GetColumnIndex("ProcessID");
8989
auto idxTimeInSeconds = csv.GetColumnIndex("TimeInSeconds");
9090
auto idxQPCTime = csv.GetColumnIndex("QPCTime");
91-
ASSERT_NE(idxProcessID, SIZE_MAX) << " Output missing required column: ProcessID";
92-
ASSERT_NE(idxTimeInSeconds, SIZE_MAX) << " Output missing required column: TimeInSeconds";
93-
ASSERT_NE(idxQPCTime, SIZE_MAX) << " Output missing required column: QPCTime";
91+
if (idxProcessID == SIZE_MAX) AddTestFailure(__FILE__, __LINE__, " Output missing required column: ProcessID");
92+
if (idxTimeInSeconds == SIZE_MAX) AddTestFailure(__FILE__, __LINE__, " Output missing required column: TimeInSeconds");
93+
if (idxQPCTime == SIZE_MAX) AddTestFailure(__FILE__, __LINE__, " Output missing required column: QPCTime");
94+
if (::testing::Test::HasFailure()) {
95+
return;
96+
}
9497

9598
// TimeInSeconds is only ordered per-process, so we track each process separately
9699
std::unordered_map<uint32_t, std::pair<double, T>> firstMeasurement;
@@ -119,9 +122,10 @@ void QpcTimeTest(wchar_t const* qpcTimeArg)
119122
}
120123
csv.Close();
121124

122-
ASSERT_GT(csv.line_, 1u)
123-
<< " PresentMon didn't capture any presents during the test.\n"
124-
" Re-run the test with a graphics application running.";
125+
if (csv.line_ <= 1u) {
126+
AddTestFailure(__FILE__, __LINE__, " PresentMon didn't capture any presents during the test.\n"
127+
" Re-run the test with a graphics application running.");
128+
}
125129

126130
if (::testing::Test::HasFailure()) {
127131
printf("%ls\n", csvPath.c_str());

Tests/GoldEtlCsvTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class Tests : public ::testing::Test, TestArgs {
141141
if (CreateProcessW(nullptr, &cmd[0], nullptr, nullptr, TRUE, 0, nullptr, nullptr, &si, &pi) == 0) {
142142
printf("error: failed to execute diff request: %ls\n", cmd.c_str());
143143
} else {
144+
CloseHandle(pi.hThread);
144145
CloseHandle(pi.hProcess);
145146
}
146147
}

Tests/PresentMon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ bool PresentMonCsv::ReadRow()
190190
size_t PresentMonCsv::GetColumnIndex(char const* header) const
191191
{
192192
auto h = FindHeader(header);
193-
return h == UnknownHeader ? SIZE_MAX : headerColumnIndex_[h];
193+
return h < KnownHeaderCount ? headerColumnIndex_[h] : SIZE_MAX;
194194
}
195195

196196
PresentMon::PresentMon()

0 commit comments

Comments
 (0)