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<unsigned long, long>' 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<false>::Compare<unsigned long, long>' 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<GTEST_IS_NULL_LITERAL_(val1)>::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<false>::Compare<unsigned long, long>' requested here
    EXPECT_EQ(GetLastError(), ERROR_FILE_NOT_FOUND)
    ^

Change-Id: I55b33b39c271d765376ff9c416e737d0608eb781
Reviewed-on: https://chromium-review.googlesource.com/742561
Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
Mark Mentovai 2017-10-28 08:19:12 -04:00
parent 692488a254
commit 3fae8ff07c
2 changed files with 7 additions and 8 deletions

View File

@ -34,10 +34,10 @@
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
crashpad::test::InitializeMainArguments(argc, argv); crashpad::test::InitializeMainArguments(argc, argv);
#if defined(CRASHPAD_TEST_LAUNCHER_GTEST) #if defined(CRASHPAD_TEST_LAUNCHER_GMOCK)
testing::InitGoogleTest(&argc, argv);
#elif defined(CRASHPAD_TEST_LAUNCHER_GMOCK)
testing::InitGoogleMock(&argc, argv); testing::InitGoogleMock(&argc, argv);
#elif defined(CRASHPAD_TEST_LAUNCHER_GTEST)
testing::InitGoogleTest(&argc, argv);
#else // CRASHPAD_TEST_LAUNCHER_GTEST #else // CRASHPAD_TEST_LAUNCHER_GTEST
#error #define CRASHPAD_TEST_LAUNCHER_GTEST or CRASHPAD_TEST_LAUNCHER_GMOCK #error #define CRASHPAD_TEST_LAUNCHER_GTEST or CRASHPAD_TEST_LAUNCHER_GMOCK
#endif // CRASHPAD_TEST_LAUNCHER_GTEST #endif // CRASHPAD_TEST_LAUNCHER_GTEST

View File

@ -70,13 +70,12 @@ bool SymbolicLinkFlags(DWORD* flags) {
// Dont use ErrorMessage() here because the second CreateSymbolicLink() may // Dont use ErrorMessage() here because the second CreateSymbolicLink() may
// have scrambled it. Use the saved |error| value instead. // have scrambled it. Use the saved |error| value instead.
EXPECT_EQ(error, ERROR_PRIVILEGE_NOT_HELD) EXPECT_EQ(error, static_cast<DWORD>(ERROR_PRIVILEGE_NOT_HELD))
<< "CreateSymbolicLink: " << "CreateSymbolicLink: " << logging::SystemErrorCodeToString(error);
<< logging::SystemErrorCodeToString(GetLastError());
return -1; return -1;
}(); }();
if (symbolic_link_flags == -1) { if (symbolic_link_flags == static_cast<DWORD>(-1)) {
return false; return false;
} }
@ -108,7 +107,7 @@ bool PathExists(const base::FilePath& path) {
return true; return true;
#elif defined(OS_WIN) #elif defined(OS_WIN)
if (GetFileAttributes(path.value().c_str()) == INVALID_FILE_ATTRIBUTES) { if (GetFileAttributes(path.value().c_str()) == INVALID_FILE_ATTRIBUTES) {
EXPECT_EQ(GetLastError(), ERROR_FILE_NOT_FOUND) EXPECT_EQ(GetLastError(), static_cast<DWORD>(ERROR_FILE_NOT_FOUND))
<< ErrorMessage("GetFileAttributes ") << ErrorMessage("GetFileAttributes ")
<< base::UTF16ToUTF8(path.value()); << base::UTF16ToUTF8(path.value());
return false; return false;