From 6082aed2f2978692f0be921bac26608f4afd5aa3 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Mon, 21 Sep 2015 10:51:15 -0700 Subject: [PATCH] win: Get Crashpad compiling under VS2015 R=mark@chromium.org BUG=crashpad:1, chromium:440500 Review URL: https://codereview.chromium.org/1357833002 . --- client/crashpad_client_win.cc | 4 ++-- client/settings.cc | 3 +-- compat/win/sys/types.h | 4 ++++ compat/win/time.h | 5 +++++ minidump/minidump_file_writer_test.cc | 1 + snapshot/win/system_snapshot_win_test.cc | 4 ++++ test/win/win_child_process.cc | 4 ++-- util/win/exception_handler_server.cc | 8 +++++--- util/win/module_version.cc | 4 ++-- util/win/process_info.cc | 23 +++++++++++------------ util/win/scoped_process_suspend_test.cc | 4 ++-- 11 files changed, 39 insertions(+), 25 deletions(-) diff --git a/client/crashpad_client_win.cc b/client/crashpad_client_win.cc index b2ab03a0..e19aa746 100644 --- a/client/crashpad_client_win.cc +++ b/client/crashpad_client_win.cc @@ -118,8 +118,8 @@ bool CrashpadClient::SetHandler(const std::string& ipc_port) { } // The server returns these already duplicated to be valid in this process. - g_signal_exception = - reinterpret_cast(response.registration.request_report_event); + g_signal_exception = reinterpret_cast( + static_cast(response.registration.request_report_event)); return true; } diff --git a/client/settings.cc b/client/settings.cc index d1b35f1a..9467a523 100644 --- a/client/settings.cc +++ b/client/settings.cc @@ -16,7 +16,6 @@ #include -#include "base/compiler_specific.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" #include "util/numeric/in_range_cast.h" @@ -40,7 +39,7 @@ void ScopedLockedFileHandleTraits::Free(FileHandle handle) { } // namespace internal -struct ALIGNAS(4) Settings::Data { +struct Settings::Data { static const uint32_t kSettingsMagic = 'CPds'; static const uint32_t kSettingsVersion = 1; diff --git a/compat/win/sys/types.h b/compat/win/sys/types.h index b6463a0c..31797321 100644 --- a/compat/win/sys/types.h +++ b/compat/win/sys/types.h @@ -16,7 +16,11 @@ #define CRASHPAD_COMPAT_WIN_SYS_TYPES_H_ // This is intended to be roughly equivalent to #include_next. +#if _MSC_VER < 1900 #include <../include/sys/types.h> +#else +#include <../ucrt/sys/types.h> +#endif #include diff --git a/compat/win/time.h b/compat/win/time.h index 7c6adc2c..913b4694 100644 --- a/compat/win/time.h +++ b/compat/win/time.h @@ -15,7 +15,12 @@ #ifndef CRASHPAD_COMPAT_WIN_TIME_H_ #define CRASHPAD_COMPAT_WIN_TIME_H_ +// This is intended to be roughly equivalent to #include_next. +#if _MSC_VER < 1900 #include <../include/time.h> +#else +#include <../ucrt/time.h> +#endif #ifdef __cplusplus extern "C" { diff --git a/minidump/minidump_file_writer_test.cc b/minidump/minidump_file_writer_test.cc index cc6b1ce5..147d5c8a 100644 --- a/minidump/minidump_file_writer_test.cc +++ b/minidump/minidump_file_writer_test.cc @@ -290,6 +290,7 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) { // but the test should complete without failure. const uint32_t kSnapshotTime = 0xfd469ab8; MSVC_SUPPRESS_WARNING(4309); // Truncation of constant value. + MSVC_SUPPRESS_WARNING(4838); // Narrowing conversion. const timeval kSnapshotTimeval = { static_cast(kSnapshotTime), 0 }; TestProcessSnapshot process_snapshot; diff --git a/snapshot/win/system_snapshot_win_test.cc b/snapshot/win/system_snapshot_win_test.cc index 735b2f45..d0caee7d 100644 --- a/snapshot/win/system_snapshot_win_test.cc +++ b/snapshot/win/system_snapshot_win_test.cc @@ -123,6 +123,10 @@ TEST_F(SystemSnapshotWinTest, TimeZone) { // |standard_offset_seconds| gives seconds east of UTC, and |timezone| gives // seconds west of UTC. +#if _MSC_VER >= 1900 + long timezone = 0; + _get_timezone(&timezone); +#endif EXPECT_EQ(-timezone, standard_offset_seconds); // In contemporary usage, most time zones have an integer hour offset from diff --git a/test/win/win_child_process.cc b/test/win/win_child_process.cc index b0efa462..577b6b63 100644 --- a/test/win/win_child_process.cc +++ b/test/win/win_child_process.cc @@ -152,8 +152,8 @@ WinChildProcess::WinChildProcess() { unsigned int write, read; CHECK(StringToNumber(left, &write)); CHECK(StringToNumber(right, &read)); - pipe_write_.reset(reinterpret_cast(write)); - pipe_read_.reset(reinterpret_cast(read)); + pipe_write_.reset(reinterpret_cast(static_cast(write))); + pipe_read_.reset(reinterpret_cast(static_cast(read))); // Notify the parent that it's OK to proceed. We only need to wait to get to // the process entry point, but this is the easiest place we can notify. diff --git a/util/win/exception_handler_server.cc b/util/win/exception_handler_server.cc index 50a5fa3c..bcdec6a2 100644 --- a/util/win/exception_handler_server.cc +++ b/util/win/exception_handler_server.cc @@ -17,6 +17,7 @@ #include #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "base/rand_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -351,7 +352,7 @@ bool ExceptionHandlerServer::ServiceClientConnection( PLOG(ERROR) << "ImpersonateNamedPipeClient"; return false; } - HANDLE client_process = OpenProcess( + client_process = OpenProcess( kXPProcessAllAccess, false, message.registration.client_process_id); PCHECK(RevertToSelf()); if (!client_process) { @@ -375,8 +376,9 @@ bool ExceptionHandlerServer::ServiceClientConnection( // Duplicate the events back to the client so they can request a dump. ServerToClientMessage response; - response.registration.request_report_event = reinterpret_cast( - DuplicateEvent(client->process(), client->dump_requested_event())); + response.registration.request_report_event = + base::checked_cast(reinterpret_cast( + DuplicateEvent(client->process(), client->dump_requested_event()))); if (!LoggingWriteFile(service_context.pipe(), &response, sizeof(response))) return false; diff --git a/util/win/module_version.cc b/util/win/module_version.cc index a887b2c7..bcd98c0e 100644 --- a/util/win/module_version.cc +++ b/util/win/module_version.cc @@ -35,11 +35,11 @@ bool GetModuleVersionAndType(const base::FilePath& path, << base::UTF16ToUTF8(path.value()); } else { VS_FIXEDFILEINFO* fixed_file_info; - UINT size; + UINT ffi_size; if (!VerQueryValue(data.get(), L"\\", reinterpret_cast(&fixed_file_info), - &size)) { + &ffi_size)) { PLOG(WARNING) << "VerQueryValue"; } else { *vs_fixedfileinfo = *fixed_file_info; diff --git a/util/win/process_info.cc b/util/win/process_info.cc index f7d1c5de..64fb79b0 100644 --- a/util/win/process_info.cc +++ b/util/win/process_info.cc @@ -68,11 +68,12 @@ bool ReadUnicodeString(HANDLE process, DCHECK_EQ(us.Length % sizeof(wchar_t), 0u); result->resize(us.Length / sizeof(wchar_t)); SIZE_T bytes_read; - if (!ReadProcessMemory(process, - reinterpret_cast(us.Buffer), - &result->operator[](0), - us.Length, - &bytes_read)) { + if (!ReadProcessMemory( + process, + reinterpret_cast(static_cast(us.Buffer)), + &result->operator[](0), + us.Length, + &bytes_read)) { PLOG(ERROR) << "ReadProcessMemory UNICODE_STRING"; return false; } @@ -198,11 +199,10 @@ bool ReadProcessData(HANDLE process, // Include the first module in the memory order list to get our the main // executable's name, as it's not included in initialization order below. if (!ReadStruct(process, - reinterpret_cast( - reinterpret_cast( - peb_ldr_data.InMemoryOrderModuleList.Flink) - + static_cast( + peb_ldr_data.InMemoryOrderModuleList.Flink) - offsetof(process_types::LDR_DATA_TABLE_ENTRY, - InMemoryOrderLinks)), + InMemoryOrderLinks), &ldr_data_table_entry)) { return false; } @@ -228,10 +228,9 @@ bool ReadProcessData(HANDLE process, // to read from the target, and also offset back to the beginning of the // structure. if (!ReadStruct(process, - reinterpret_cast( - reinterpret_cast(cur) - + static_cast(cur) - offsetof(process_types::LDR_DATA_TABLE_ENTRY, - InInitializationOrderLinks)), + InInitializationOrderLinks), &ldr_data_table_entry)) { break; } diff --git a/util/win/scoped_process_suspend_test.cc b/util/win/scoped_process_suspend_test.cc index f663d38b..5b7813df 100644 --- a/util/win/scoped_process_suspend_test.cc +++ b/util/win/scoped_process_suspend_test.cc @@ -95,11 +95,11 @@ TEST(ScopedProcessSuspend, ScopedProcessSuspend) { EXPECT_TRUE(SuspendCountMatches(handles->process.get(), 0)); { - ScopedProcessSuspend suspend(handles->process.get()); + ScopedProcessSuspend suspend0(handles->process.get()); EXPECT_TRUE(SuspendCountMatches(handles->process.get(), 1)); { - ScopedProcessSuspend suspend(handles->process.get()); + ScopedProcessSuspend suspend1(handles->process.get()); EXPECT_TRUE(SuspendCountMatches(handles->process.get(), 2)); }