From cf51e77d6d7cf5302f03812bb726a86e9be572f5 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Fri, 28 Jun 2019 15:28:24 -0700 Subject: Fix suggestions from clang. PiperOrigin-RevId: 255679603 --- test/syscalls/linux/mmap.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'test/syscalls/linux/mmap.cc') diff --git a/test/syscalls/linux/mmap.cc b/test/syscalls/linux/mmap.cc index 5b5b4c2e8..a112316e9 100644 --- a/test/syscalls/linux/mmap.cc +++ b/test/syscalls/linux/mmap.cc @@ -113,7 +113,7 @@ class MMapTest : public ::testing::Test { size_t length_ = 0; }; -// Matches if arg contains the same contents as std::string str. +// Matches if arg contains the same contents as string str. MATCHER_P(EqualsMemory, str, "") { if (0 == memcmp(arg, str.c_str(), str.size())) { return true; @@ -1086,8 +1086,8 @@ TEST_F(MMapFileTest, WriteShared) { ASSERT_THAT(Read(buf.data(), buf.size()), SyscallSucceedsWithValue(buf.size())); // Cast to void* to avoid EXPECT_THAT assuming buf.data() is a - // NUL-terminated C std::string. EXPECT_THAT will try to print a char* as a C - // std::string, possibly overruning the buffer. + // NUL-terminated C string. EXPECT_THAT will try to print a char* as a C + // string, possibly overruning the buffer. EXPECT_THAT(reinterpret_cast(buf.data()), EqualsMemory(std::string(kFileContents))); } @@ -1122,6 +1122,7 @@ TEST_F(MMapFileTest, WriteSharedBeyondEnd) { ASSERT_THAT(Read(buf.data(), buf.size()), SyscallSucceedsWithValue(first.size())); // Cast to void* to avoid EXPECT_THAT assuming buf.data() is a + // NUL-terminated C string. EXPECT_THAT will try to print a char* as a C // NUL-terminated C std::string. EXPECT_THAT will try to print a char* as a C // std::string, possibly overruning the buffer. EXPECT_THAT(reinterpret_cast(buf.data()), EqualsMemory(first)); @@ -1159,8 +1160,8 @@ TEST_F(MMapFileTest, WriteSharedTruncateUp) { ASSERT_THAT(Read(buf.data(), buf.size()), SyscallSucceedsWithValue(buf.size())); // Cast to void* to avoid EXPECT_THAT assuming buf.data() is a - // NUL-terminated C std::string. EXPECT_THAT will try to print a char* as a C - // std::string, possibly overruning the buffer. + // NUL-terminated C string. EXPECT_THAT will try to print a char* as a C + // string, possibly overruning the buffer. EXPECT_THAT(reinterpret_cast(buf.data()), EqualsMemory(first)); EXPECT_THAT(reinterpret_cast(buf.data() + kPageSize / 2), EqualsMemory(second)); @@ -1234,8 +1235,8 @@ TEST_F(MMapFileTest, WriteSharedTruncateDownThenUp) { ASSERT_THAT(Read(buf.data(), buf.size()), SyscallSucceedsWithValue(buf.size())); // Cast to void* to avoid EXPECT_THAT assuming buf.data() is a - // NUL-terminated C std::string. EXPECT_THAT will try to print a char* as a C - // std::string, possibly overruning the buffer. + // NUL-terminated C string. EXPECT_THAT will try to print a char* as a C + // string, possibly overruning the buffer. EXPECT_THAT(reinterpret_cast(buf.data()), EqualsMemory(zeroed)); } @@ -1363,8 +1364,8 @@ TEST_F(MMapFileTest, WritePrivate) { ASSERT_THAT(Read(buf.data(), buf.size()), SyscallSucceedsWithValue(buf.size())); // Cast to void* to avoid EXPECT_THAT assuming buf.data() is a - // NUL-terminated C std::string. EXPECT_THAT will try to print a char* as a C - // std::string, possibly overruning the buffer. + // NUL-terminated C string. EXPECT_THAT will try to print a char* as a C + // string, possibly overruning the buffer. EXPECT_THAT(reinterpret_cast(buf.data()), EqualsMemory(std::string(len, '\0'))); } -- cgit v1.2.3