mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-26 23:01:05 +08:00
Tidy up to enable C4800 on Windows
Fixes two incorrect usages of ssize_t/off_t being implicitly converted to bool. As such, I think it's worth the cost of the additional !! on BOOL returning Win32 functions. R=mark@chromium.org Review URL: https://codereview.chromium.org/1408123006 .
This commit is contained in:
parent
80f50467c3
commit
4b780ba040
@ -159,7 +159,7 @@ ReportDisk::ReportDisk(const MetadataFileReportRecord& record,
|
||||
base::UTF8ToUTF16(&string_table[record.file_path_index]));
|
||||
id = &string_table[record.id_index];
|
||||
creation_time = record.creation_time;
|
||||
uploaded = record.uploaded;
|
||||
uploaded = record.uploaded != 0;
|
||||
last_upload_attempt_time = record.last_upload_attempt_time;
|
||||
upload_attempts = record.upload_attempts;
|
||||
state = static_cast<ReportState>(record.state);
|
||||
|
@ -229,7 +229,7 @@ void CrashpadClient::DumpWithoutCrash(const CONTEXT& context) {
|
||||
g_non_crash_exception_information.exception_pointers =
|
||||
reinterpret_cast<crashpad::WinVMAddress>(&exception_pointers);
|
||||
|
||||
bool set_event_result = SetEvent(g_signal_non_crash_dump);
|
||||
bool set_event_result = !!SetEvent(g_signal_non_crash_dump);
|
||||
PLOG_IF(ERROR, !set_event_result) << "SetEvent";
|
||||
|
||||
DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE);
|
||||
|
@ -250,10 +250,12 @@ bool Settings::ReadSettings(FileHandle handle,
|
||||
return false;
|
||||
|
||||
bool read_result;
|
||||
if (log_read_error)
|
||||
if (log_read_error) {
|
||||
read_result = LoggingReadFile(handle, out_data, sizeof(*out_data));
|
||||
else
|
||||
read_result = ReadFile(handle, out_data, sizeof(*out_data));
|
||||
} else {
|
||||
read_result =
|
||||
ReadFile(handle, out_data, sizeof(*out_data)) == sizeof(*out_data);
|
||||
}
|
||||
|
||||
if (!read_result)
|
||||
return false;
|
||||
|
@ -173,7 +173,7 @@ bool MinidumpFileWriter::WriteEverything(FileWriterInterface* file_writer) {
|
||||
|
||||
// Seek back to the end of the file, in case some non-minidump content will be
|
||||
// written to the file after the minidump content.
|
||||
return file_writer->Seek(end_offset, SEEK_SET);
|
||||
return file_writer->Seek(end_offset, SEEK_SET) >= 0;
|
||||
}
|
||||
|
||||
bool MinidumpFileWriter::Freeze() {
|
||||
|
@ -158,8 +158,7 @@ void ExpectMiscellaneousDebugRecord(
|
||||
*misc_record);
|
||||
ASSERT_TRUE(misc_debug_record);
|
||||
EXPECT_EQ(expected_debug_type, misc_debug_record->DataType);
|
||||
EXPECT_EQ(expected_debug_utf16,
|
||||
static_cast<bool>(misc_debug_record->Unicode));
|
||||
EXPECT_EQ(expected_debug_utf16, misc_debug_record->Unicode != 0);
|
||||
EXPECT_EQ(0u, misc_debug_record->Reserved[0]);
|
||||
EXPECT_EQ(0u, misc_debug_record->Reserved[1]);
|
||||
EXPECT_EQ(0u, misc_debug_record->Reserved[2]);
|
||||
|
@ -40,7 +40,7 @@ uint16_t CPUContextX86::FxsaveToFsaveTagWord(
|
||||
|
||||
uint16_t fsave_tag = 0;
|
||||
for (int physical_index = 0; physical_index < 8; ++physical_index) {
|
||||
bool fxsave_bit = fxsave_tag & (1 << physical_index);
|
||||
bool fxsave_bit = (fxsave_tag & (1 << physical_index)) != 0;
|
||||
uint8_t fsave_bits;
|
||||
|
||||
if (fxsave_bit) {
|
||||
@ -55,7 +55,7 @@ uint16_t CPUContextX86::FxsaveToFsaveTagWord(
|
||||
fsave_bits = kX87TagSpecial;
|
||||
} else {
|
||||
// The integer bit the “J bit”.
|
||||
bool integer_bit = st[7] & 0x80;
|
||||
bool integer_bit = (st[7] & 0x80) != 0;
|
||||
if (exponent == 0) {
|
||||
uint64_t fraction = ((implicit_cast<uint64_t>(st[7]) & 0x7f) << 56) |
|
||||
(implicit_cast<uint64_t>(st[6]) << 48) |
|
||||
|
@ -274,7 +274,7 @@ bool SystemSnapshotWin::CPUX86SupportsDAZ() const {
|
||||
uint32_t mxcsr_mask = extended_registers[7];
|
||||
|
||||
// Test the DAZ bit.
|
||||
return mxcsr_mask & (1 << 6);
|
||||
return (mxcsr_mask & (1 << 6)) != 0;
|
||||
}
|
||||
|
||||
SystemSnapshot::OperatingSystem SystemSnapshotWin::GetOperatingSystem() const {
|
||||
@ -311,7 +311,7 @@ std::string SystemSnapshotWin::MachineDescription() const {
|
||||
|
||||
bool SystemSnapshotWin::NXEnabled() const {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
return IsProcessorFeaturePresent(PF_NX_ENABLED);
|
||||
return !!IsProcessorFeaturePresent(PF_NX_ENABLED);
|
||||
}
|
||||
|
||||
void SystemSnapshotWin::TimeZone(DaylightSavingTimeStatus* dst_status,
|
||||
|
@ -233,7 +233,7 @@ bool LoggingTruncateFile(FileHandle file) {
|
||||
bool LoggingCloseFile(FileHandle file) {
|
||||
BOOL rv = CloseHandle(file);
|
||||
PLOG_IF(ERROR, !rv) << "CloseHandle";
|
||||
return rv;
|
||||
return !!rv;
|
||||
}
|
||||
|
||||
} // namespace crashpad
|
||||
|
@ -21,13 +21,13 @@ namespace crashpad {
|
||||
|
||||
namespace {
|
||||
|
||||
BOOL CrashpadInitializeCriticalSectionEx(
|
||||
bool CrashpadInitializeCriticalSectionEx(
|
||||
CRITICAL_SECTION* critical_section,
|
||||
DWORD spin_count,
|
||||
DWORD flags) {
|
||||
static const auto initialize_critical_section_ex =
|
||||
GET_FUNCTION_REQUIRED(L"kernel32.dll", ::InitializeCriticalSectionEx);
|
||||
bool ret =
|
||||
BOOL ret =
|
||||
initialize_critical_section_ex(critical_section, spin_count, flags);
|
||||
if (!ret) {
|
||||
PLOG(ERROR) << "InitializeCriticalSectionEx";
|
||||
|
@ -450,7 +450,7 @@ DWORD __stdcall ExceptionHandlerServer::PipeServiceProc(void* ctx) {
|
||||
DCHECK(service_context);
|
||||
|
||||
for (;;) {
|
||||
bool ret = ConnectNamedPipe(service_context->pipe(), nullptr);
|
||||
bool ret = !!ConnectNamedPipe(service_context->pipe(), nullptr);
|
||||
if (!ret && GetLastError() != ERROR_PIPE_CONNECTED) {
|
||||
PLOG(ERROR) << "ConnectNamedPipe";
|
||||
} else if (ServiceClientConnection(*service_context)) {
|
||||
@ -491,7 +491,7 @@ void __stdcall ExceptionHandlerServer::OnNonCrashDumpEvent(void* ctx, BOOLEAN) {
|
||||
client->non_crash_exception_information_address(),
|
||||
client->debug_critical_section_address());
|
||||
|
||||
bool result = SetEvent(client->non_crash_dump_completed_event());
|
||||
bool result = !!SetEvent(client->non_crash_dump_completed_event());
|
||||
PLOG_IF(ERROR, !result) << "SetEvent";
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ bool IsProcessWow64(HANDLE process_handle) {
|
||||
PLOG(ERROR) << "IsWow64Process";
|
||||
return false;
|
||||
}
|
||||
return is_wow64;
|
||||
return !!is_wow64;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -50,7 +50,7 @@ bool IsProcessWow64(HANDLE process_handle) {
|
||||
PLOG(ERROR) << "IsWow64Process";
|
||||
return false;
|
||||
}
|
||||
return is_wow64;
|
||||
return !!is_wow64;
|
||||
}
|
||||
|
||||
void VerifyAddressInInCodePage(const ProcessInfo& process_info,
|
||||
|
Loading…
x
Reference in New Issue
Block a user