diff options
author | Mike Frysinger <vapier@chromium.org> | 2016-01-21 00:50:28 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@chromium.org> | 2016-01-21 00:50:28 -0500 |
commit | 8baa236daa9a2bab20e7b5cdaaee52c0de43cc40 (patch) | |
tree | 055a292403ea90d6ab71aca3f80ec9977968998a | |
parent | Fix usage of snprintf for MSVC (diff) | |
download | breakpad-8baa236daa9a2bab20e7b5cdaaee52c0de43cc40.tar.xz |
exploitability_unittest: fix warnings
The std::getline function always returns its first arg (which is an
iostream object) and cannot return anything else. Thus, testing its
value is pointless, and even leads to build errors w/at least gcc-5
due to gtest ASSERT_TRUE funcs only taking bool types:
.../exploitability_unittest.cc: In member function 'virtual void {anonymous}::ExploitabilityLinuxUtilsTest_DisassembleBytesTest_Test::TestBody()':
.../exploitability_unittest.cc:200:136: error: no matching function for call to 'testing::AssertionResult::AssertionResult(std::basic_istream<char>&)'
In file included from .../breakpad_googletest_includes.h:33:0,
from .../exploitability_unittest.cc:35:
.../gtest.h:262:12: note: candidate: testing::AssertionResult::AssertionResult(bool)
Since we know this never fails, simply drop the ASSERT_TRUE usage.
The next line already checks the content of the buffer we read.
Further on in the file, we hit some signed warnings:
In file included from .../breakpad_googletest_includes.h:33:0,
from .../exploitability_unittest.cc:35:
.../gtest.h: In instantiation of 'testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const char*, const T1&, const T2&) [with T1 = long unsigned int; T2 = int]':
.../gtest.h:1484:23: required from 'static testing::AssertionResult testing::internal::EqHelper<lhs_is_null_literal>::Compare(const char*, const char*, const T1&, const T2&) [with T1 = long unsigned int; T2 = int; bool lhs_is_null_literal = false]'
.../exploitability_unittest.cc:241:289: required from here
.../gtest.h:1448:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (expected == actual) {
This is because we compare the register value (a uint64_t) directly to
an integer constant, and those are signed by default. Stick a U suffix
on them to fix things up.
BUG=chromium:579384
TEST=`make check` passes
R=ivanpe@chromium.org
Review URL: https://codereview.chromium.org/1611763002 .
-rw-r--r-- | src/processor/exploitability_unittest.cc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/processor/exploitability_unittest.cc b/src/processor/exploitability_unittest.cc index dc5650e3..ec845bf0 100644 --- a/src/processor/exploitability_unittest.cc +++ b/src/processor/exploitability_unittest.cc @@ -194,10 +194,9 @@ TEST(ExploitabilityLinuxUtilsTest, DisassembleBytesTest) { std::stringstream objdump_stream; objdump_stream.str(string(buffer)); string line = ""; - while ((line.find("<.data>") == string::npos) && - getline(objdump_stream, line)) { - } - ASSERT_TRUE(getline(objdump_stream, line)); + while (line.find("<.data>") == string::npos) + getline(objdump_stream, line); + getline(objdump_stream, line); ASSERT_EQ(line, " 0:\tc7 00 05 00 00 00 \tmov DWORD PTR [rax],0x5"); } @@ -239,17 +238,17 @@ TEST(ExploitabilityLinuxUtilsTest, CalculateAddressTest) { MDRawContextAMD64 raw_context; raw_context.rdx = 12345; ExploitabilityLinuxTestMinidumpContext context(raw_context); - ASSERT_EQ(context.GetContextAMD64()->rdx, 12345); + ASSERT_EQ(context.GetContextAMD64()->rdx, 12345U); ASSERT_FALSE(ExploitabilityLinuxTest::CalculateAddress("", context, NULL)); uint64_t write_address = 0; ASSERT_TRUE(ExploitabilityLinuxTest::CalculateAddress("rdx-0x4D2", context, &write_address)); - ASSERT_EQ(write_address, 11111); + ASSERT_EQ(write_address, 11111U); ASSERT_TRUE(ExploitabilityLinuxTest::CalculateAddress("rdx+0x4D2", context, &write_address)); - ASSERT_EQ(write_address, 13579); + ASSERT_EQ(write_address, 13579U); ASSERT_FALSE(ExploitabilityLinuxTest::CalculateAddress("rdx+rax", context, &write_address)); |