From 3fae8ff07c097da6d0042510bdbe5b16c67a8e12 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Sat, 28 Oct 2017 08:19:12 -0400 Subject: [PATCH] win: Fix -Wsign-compare warnings produced by clang ../../third_party/crashpad/crashpad/util/file/filesystem_test_util.cc(79,27): error: comparison of integers of different signs: 'DWORD' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] if (symbolic_link_flags == -1) { ~~~~~~~~~~~~~~~~~~~ ^ ~~ In file included from ../../third_party/crashpad/crashpad/util/file/filesystem_test_util.cc:23: ../../third_party/googletest/src/googletest/include\gtest/gtest.h(1392,11): error: comparison of integers of different signs: 'const unsigned long' and 'const long' [-Werror,-Wsign-compare] if (lhs == rhs) { ~~~ ^ ~~~ ../../third_party/googletest/src/googletest/include\gtest/gtest.h(1421,12): note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ' requested here return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); ^ ../../third_party/crashpad/crashpad/util/file/filesystem_test_util.cc(73,5): note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare' requested here EXPECT_EQ(error, ERROR_PRIVILEGE_NOT_HELD) ^ ../../third_party/googletest/src/googletest/include\gtest/gtest.h(1924,63): note: expanded from macro 'EXPECT_EQ' EqHelper::Compare, \ ^ 2 errors generated. and ../../third_party/crashpad/crashpad/util/file/filesystem_test_util.cc(111,5): note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare' requested here EXPECT_EQ(GetLastError(), ERROR_FILE_NOT_FOUND) ^ Change-Id: I55b33b39c271d765376ff9c416e737d0608eb781 Reviewed-on: https://chromium-review.googlesource.com/742561 Reviewed-by: Scott Graham --- test/gtest_main.cc | 6 +++--- util/file/filesystem_test_util.cc | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/test/gtest_main.cc b/test/gtest_main.cc index 1e9b6b11..6e082828 100644 --- a/test/gtest_main.cc +++ b/test/gtest_main.cc @@ -34,10 +34,10 @@ int main(int argc, char* argv[]) { crashpad::test::InitializeMainArguments(argc, argv); -#if defined(CRASHPAD_TEST_LAUNCHER_GTEST) - testing::InitGoogleTest(&argc, argv); -#elif defined(CRASHPAD_TEST_LAUNCHER_GMOCK) +#if defined(CRASHPAD_TEST_LAUNCHER_GMOCK) testing::InitGoogleMock(&argc, argv); +#elif defined(CRASHPAD_TEST_LAUNCHER_GTEST) + testing::InitGoogleTest(&argc, argv); #else // CRASHPAD_TEST_LAUNCHER_GTEST #error #define CRASHPAD_TEST_LAUNCHER_GTEST or CRASHPAD_TEST_LAUNCHER_GMOCK #endif // CRASHPAD_TEST_LAUNCHER_GTEST diff --git a/util/file/filesystem_test_util.cc b/util/file/filesystem_test_util.cc index 42cc8eb3..5d991ee7 100644 --- a/util/file/filesystem_test_util.cc +++ b/util/file/filesystem_test_util.cc @@ -70,13 +70,12 @@ bool SymbolicLinkFlags(DWORD* flags) { // Don’t use ErrorMessage() here because the second CreateSymbolicLink() may // have scrambled it. Use the saved |error| value instead. - EXPECT_EQ(error, ERROR_PRIVILEGE_NOT_HELD) - << "CreateSymbolicLink: " - << logging::SystemErrorCodeToString(GetLastError()); + EXPECT_EQ(error, static_cast(ERROR_PRIVILEGE_NOT_HELD)) + << "CreateSymbolicLink: " << logging::SystemErrorCodeToString(error); return -1; }(); - if (symbolic_link_flags == -1) { + if (symbolic_link_flags == static_cast(-1)) { return false; } @@ -108,7 +107,7 @@ bool PathExists(const base::FilePath& path) { return true; #elif defined(OS_WIN) if (GetFileAttributes(path.value().c_str()) == INVALID_FILE_ATTRIBUTES) { - EXPECT_EQ(GetLastError(), ERROR_FILE_NOT_FOUND) + EXPECT_EQ(GetLastError(), static_cast(ERROR_FILE_NOT_FOUND)) << ErrorMessage("GetFileAttributes ") << base::UTF16ToUTF8(path.value()); return false;