diff options
68 files changed, 427 insertions, 372 deletions
diff --git a/base/file_version_info_unittest.cc b/base/file_version_info_unittest.cc index c5e9859..d4ab954 100644 --- a/base/file_version_info_unittest.cc +++ b/base/file_version_info_unittest.cc @@ -93,7 +93,7 @@ TEST(FileVersionInfoTest, IsOfficialBuild) { // Test consistency check. ASSERT_EQ(arraysize(kDLLNames), arraysize(kExpected)); - for (int i = 0; i < arraysize(kDLLNames); ++i) { + for (size_t i = 0; i < arraysize(kDLLNames); ++i) { FilePath dll_path = GetTestDataPath(); dll_path = dll_path.Append(kDLLNames[i]); diff --git a/base/file_version_info_win.cc b/base/file_version_info_win.cc index ca3e4b1..a7dc216 100644 --- a/base/file_version_info_win.cc +++ b/base/file_version_info_win.cc @@ -149,7 +149,7 @@ bool FileVersionInfoWin::is_official_build() { bool FileVersionInfoWin::GetValue(const wchar_t* name, std::wstring* value_str) { WORD lang_codepage[8]; - int i = 0; + size_t i = 0; // Use the language and codepage from the DLL. lang_codepage[i++] = language_; lang_codepage[i++] = code_page_; diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc index 933cb7f..748301d 100644 --- a/base/files/file_util_unittest.cc +++ b/base/files/file_util_unittest.cc @@ -353,7 +353,8 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) { FilePath long_name = sub_a.Append(FilePath(long_name_str)); FilePath deep_file = long_name.Append(sub_long_rel).Append(deep_txt); - ASSERT_EQ(MAX_PATH - kCreateDirLimit, deep_file.value().length()); + ASSERT_EQ(static_cast<size_t>(MAX_PATH - kCreateDirLimit), + deep_file.value().length()); FilePath sub_long = deep_file.DirName(); ASSERT_TRUE(CreateDirectory(sub_long)); diff --git a/base/message_loop/message_loop_unittest.cc b/base/message_loop/message_loop_unittest.cc index dcac662..c08dc7f 100644 --- a/base/message_loop/message_loop_unittest.cc +++ b/base/message_loop/message_loop_unittest.cc @@ -336,7 +336,7 @@ void RunTest_RecursiveDenial2(MessageLoop::Type message_loop_type) { WaitForSingleObject(event.Get(), INFINITE); MessageLoop::current()->Run(); - ASSERT_EQ(order.Size(), 17); + ASSERT_EQ(17u, order.Size()); EXPECT_EQ(order.Get(0), TaskItem(RECURSIVE, 1, true)); EXPECT_EQ(order.Get(1), TaskItem(RECURSIVE, 1, false)); EXPECT_EQ(order.Get(2), TaskItem(MESSAGEBOX, 2, true)); @@ -380,7 +380,7 @@ void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) { WaitForSingleObject(event.Get(), INFINITE); MessageLoop::current()->Run(); - ASSERT_EQ(order.Size(), 18); + ASSERT_EQ(18u, order.Size()); EXPECT_EQ(order.Get(0), TaskItem(RECURSIVE, 1, true)); EXPECT_EQ(order.Get(1), TaskItem(RECURSIVE, 1, false)); EXPECT_EQ(order.Get(2), TaskItem(MESSAGEBOX, 2, true)); @@ -522,7 +522,7 @@ void TestIOHandler::Init() { DWORD read; EXPECT_FALSE(ReadFile(file_.Get(), buffer_, size(), &read, context())); - EXPECT_EQ(ERROR_IO_PENDING, GetLastError()); + EXPECT_EQ(static_cast<DWORD>(ERROR_IO_PENDING), GetLastError()); if (wait_) WaitForIO(); } @@ -615,8 +615,9 @@ void RunTest_WaitForIO() { DWORD written; EXPECT_TRUE(WriteFile(server1.Get(), buffer, sizeof(buffer), &written, NULL)); PlatformThread::Sleep(2 * delay); - EXPECT_EQ(WAIT_TIMEOUT, WaitForSingleObject(callback1_called.Get(), 0)) << - "handler1 has not been called"; + EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), + WaitForSingleObject(callback1_called.Get(), 0)) + << "handler1 has not been called"; EXPECT_TRUE(WriteFile(server2.Get(), buffer, sizeof(buffer), &written, NULL)); diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc index 08144f2..140a65c 100644 --- a/base/process/process_util_unittest.cc +++ b/base/process/process_util_unittest.cc @@ -278,7 +278,7 @@ TEST_F(ProcessUtilTest, MAYBE_GetTerminationStatusCrash) { EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_CRASHED, status); #if defined(OS_WIN) - EXPECT_EQ(0xc0000005, exit_code); + EXPECT_EQ(static_cast<int>(0xc0000005), exit_code); #elif defined(OS_POSIX) int signaled = WIFSIGNALED(exit_code); EXPECT_NE(0, signaled); diff --git a/base/profiler/native_stack_sampler_win.cc b/base/profiler/native_stack_sampler_win.cc index 87bb6ce..089b158 100644 --- a/base/profiler/native_stack_sampler_win.cc +++ b/base/profiler/native_stack_sampler_win.cc @@ -245,8 +245,8 @@ class ScopedSuspendThread { ScopedSuspendThread::ScopedSuspendThread(HANDLE thread_handle) : thread_handle_(thread_handle), - was_successful_(::SuspendThread(thread_handle) != -1) { -} + was_successful_(::SuspendThread(thread_handle) != + static_cast<DWORD>(-1)) {} ScopedSuspendThread::~ScopedSuspendThread() { if (!was_successful_) @@ -263,7 +263,8 @@ ScopedSuspendThread::~ScopedSuspendThread() { // before priority boost is reenabled. The measured length of this window is // ~100us, so this should occur fairly rarely. ScopedDisablePriorityBoost disable_priority_boost(thread_handle_); - bool resume_thread_succeeded = ::ResumeThread(thread_handle_) != -1; + bool resume_thread_succeeded = + ::ResumeThread(thread_handle_) != static_cast<DWORD>(-1); CHECK(resume_thread_succeeded) << "ResumeThread failed: " << GetLastError(); } diff --git a/base/strings/utf_string_conversions_unittest.cc b/base/strings/utf_string_conversions_unittest.cc index 97d8cbb..2d5eb41 100644 --- a/base/strings/utf_string_conversions_unittest.cc +++ b/base/strings/utf_string_conversions_unittest.cc @@ -139,13 +139,11 @@ TEST(UTFStringConversionsTest, ConvertUTF16ToUTF8) { {L"\x597d\xd800", "\xe5\xa5\xbd\xef\xbf\xbd", false}, }; - for (int i = 0; i < arraysize(convert_cases); i++) { + for (const auto& test : convert_cases) { std::string converted; - EXPECT_EQ(convert_cases[i].success, - WideToUTF8(convert_cases[i].utf16, - wcslen(convert_cases[i].utf16), - &converted)); - std::string expected(convert_cases[i].utf8); + EXPECT_EQ(test.success, + WideToUTF8(test.utf16, wcslen(test.utf16), &converted)); + std::string expected(test.utf8); EXPECT_EQ(expected, converted); } } @@ -172,13 +170,11 @@ TEST(UTFStringConversionsTest, ConvertUTF32ToUTF8) { {L"\xdc01Hello", "\xef\xbf\xbdHello", false}, }; - for (size_t i = 0; i < arraysize(convert_cases); i++) { + for (const auto& test : convert_cases) { std::string converted; - EXPECT_EQ(convert_cases[i].success, - WideToUTF8(convert_cases[i].utf32, - wcslen(convert_cases[i].utf32), - &converted)); - std::string expected(convert_cases[i].utf8); + EXPECT_EQ(test.success, + WideToUTF8(test.utf32, wcslen(test.utf32), &converted)); + std::string expected(test.utf8); EXPECT_EQ(expected, converted); } } diff --git a/base/test/test_reg_util_win_unittest.cc b/base/test/test_reg_util_win_unittest.cc index 216d58e..c38baa3 100644 --- a/base/test/test_reg_util_win_unittest.cc +++ b/base/test/test_reg_util_win_unittest.cc @@ -89,7 +89,7 @@ TEST_F(RegistryOverrideManagerTest, Basic) { read_key.Open(HKEY_CURRENT_USER, kTestKeyPath, KEY_READ)); EXPECT_TRUE(read_key.Valid()); EXPECT_EQ(ERROR_SUCCESS, read_key.ReadValueDW(kTestValueName, &value)); - EXPECT_EQ(42, value); + EXPECT_EQ(42u, value); read_key.Close(); manager_.reset(); diff --git a/base/threading/thread_local_storage.cc b/base/threading/thread_local_storage.cc index 701f6a2..ffa236f 100644 --- a/base/threading/thread_local_storage.cc +++ b/base/threading/thread_local_storage.cc @@ -76,8 +76,10 @@ void** ConstructTlsVector() { // TLS_KEY_OUT_OF_INDEXES, go ahead and set it. Otherwise, do nothing, as // another thread already did our dirty work. if (PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES != - base::subtle::NoBarrier_CompareAndSwap(&g_native_tls_key, - PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES, key)) { + static_cast<PlatformThreadLocalStorage::TLSKey>( + base::subtle::NoBarrier_CompareAndSwap( + &g_native_tls_key, + PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES, key))) { // We've been shortcut. Another thread replaced g_native_tls_key first so // we need to destroy our index and use the one the other thread got // first. diff --git a/base/threading/thread_local_storage.h b/base/threading/thread_local_storage.h index 195bff6..fa79eda 100644 --- a/base/threading/thread_local_storage.h +++ b/base/threading/thread_local_storage.h @@ -27,7 +27,7 @@ class BASE_EXPORT PlatformThreadLocalStorage { #if defined(OS_WIN) typedef unsigned long TLSKey; - enum { TLS_KEY_OUT_OF_INDEXES = TLS_OUT_OF_INDEXES }; + enum : unsigned { TLS_KEY_OUT_OF_INDEXES = TLS_OUT_OF_INDEXES }; #elif defined(OS_POSIX) typedef pthread_key_t TLSKey; // The following is a "reserved key" which is used in our generic Chromium diff --git a/base/time/time_win_unittest.cc b/base/time/time_win_unittest.cc index baaa322..e2bb893 100644 --- a/base/time/time_win_unittest.cc +++ b/base/time/time_win_unittest.cc @@ -150,11 +150,7 @@ TEST(TimeTicks, TimeGetTimeCaps) { TIMECAPS caps; MMRESULT status = timeGetDevCaps(&caps, sizeof(caps)); - EXPECT_EQ(TIMERR_NOERROR, status); - if (status != TIMERR_NOERROR) { - printf("Could not get timeGetDevCaps\n"); - return; - } + ASSERT_EQ(static_cast<MMRESULT>(MMSYSERR_NOERROR), status); EXPECT_GE(static_cast<int>(caps.wPeriodMin), 1); EXPECT_GT(static_cast<int>(caps.wPeriodMax), 1); diff --git a/base/trace_event/trace_event_etw_export_win.cc b/base/trace_event/trace_event_etw_export_win.cc index 6822eff..934c624 100644 --- a/base/trace_event/trace_event_etw_export_win.cc +++ b/base/trace_event/trace_event_etw_export_win.cc @@ -177,7 +177,7 @@ TraceEventETWExport::TraceEventETWExport() // modifications will be made by the background thread and only affect the // values of the keys (no key addition/deletion). Therefore, the map does not // require a lock for access. - for (int i = 0; i < ARRAYSIZE(kFilteredEventGroupNames); i++) + for (size_t i = 0; i < ARRAYSIZE(kFilteredEventGroupNames); i++) categories_status_[kFilteredEventGroupNames[i]] = false; categories_status_[kOtherEventsGroupName] = false; categories_status_[kDisabledOtherEventsGroupName] = false; @@ -376,7 +376,7 @@ bool TraceEventETWExport::UpdateEnabledCategories() { // recording tools) using the ETW infrastructure. This value will be set in // all Chrome processes that have registered their ETW provider. etw_match_any_keyword_ = CHROME_Context.MatchAnyKeyword; - for (int i = 0; i < ARRAYSIZE(kFilteredEventGroupNames); i++) { + for (size_t i = 0; i < ARRAYSIZE(kFilteredEventGroupNames); i++) { if (etw_match_any_keyword_ & (1ULL << i)) { categories_status_[kFilteredEventGroupNames[i]] = true; } else { diff --git a/base/win/enum_variant_unittest.cc b/base/win/enum_variant_unittest.cc index 99645a2..288c97e 100644 --- a/base/win/enum_variant_unittest.cc +++ b/base/win/enum_variant_unittest.cc @@ -31,7 +31,7 @@ TEST(EnumVariantTest, EmptyEnumVariant) { VARIANT out_element; ULONG out_received = 0; EXPECT_EQ(S_FALSE, ev->Next(1, &out_element, &out_received)); - EXPECT_EQ(0, out_received); + EXPECT_EQ(0u, out_received); EXPECT_EQ(S_FALSE, ev->Skip(1)); @@ -46,10 +46,10 @@ TEST(EnumVariantTest, EmptyEnumVariant) { EXPECT_EQ(S_OK, ev2->Reset()); ULONG ev2_finalrefcount = ev2->Release(); - EXPECT_EQ(0, ev2_finalrefcount); + EXPECT_EQ(0u, ev2_finalrefcount); ULONG ev_finalrefcount = ev->Release(); - EXPECT_EQ(0, ev_finalrefcount); + EXPECT_EQ(0u, ev_finalrefcount); } TEST(EnumVariantTest, SimpleEnumVariant) { @@ -68,12 +68,12 @@ TEST(EnumVariantTest, SimpleEnumVariant) { VARIANT out_element; ULONG out_received = 0; EXPECT_EQ(S_OK, ev->Next(1, &out_element, &out_received)); - EXPECT_EQ(1, out_received); + EXPECT_EQ(1u, out_received); EXPECT_EQ(VT_I4, out_element.vt); EXPECT_EQ(10, out_element.lVal); EXPECT_EQ(S_OK, ev->Skip(1)); EXPECT_EQ(S_OK, ev->Next(1, &out_element, &out_received)); - EXPECT_EQ(1, out_received); + EXPECT_EQ(1u, out_received); EXPECT_EQ(VT_I4, out_element.vt); EXPECT_EQ(30, out_element.lVal); EXPECT_EQ(S_FALSE, ev->Next(1, &out_element, &out_received)); @@ -82,7 +82,7 @@ TEST(EnumVariantTest, SimpleEnumVariant) { VARIANT out_elements[3]; EXPECT_EQ(S_OK, ev->Reset()); EXPECT_EQ(S_OK, ev->Next(3, out_elements, &out_received)); - EXPECT_EQ(3, out_received); + EXPECT_EQ(3u, out_received); EXPECT_EQ(VT_I4, out_elements[0].vt); EXPECT_EQ(10, out_elements[0].lVal); EXPECT_EQ(VT_I4, out_elements[1].vt); @@ -98,7 +98,7 @@ TEST(EnumVariantTest, SimpleEnumVariant) { EXPECT_EQ(S_FALSE, ev->Next(1, &out_element, &out_received)); EXPECT_EQ(S_OK, ev2->Reset()); EXPECT_EQ(S_OK, ev2->Next(3, out_elements, &out_received)); - EXPECT_EQ(3, out_received); + EXPECT_EQ(3u, out_received); EXPECT_EQ(VT_I4, out_elements[0].vt); EXPECT_EQ(10, out_elements[0].lVal); EXPECT_EQ(VT_I4, out_elements[1].vt); @@ -108,10 +108,10 @@ TEST(EnumVariantTest, SimpleEnumVariant) { EXPECT_EQ(S_FALSE, ev2->Next(1, &out_element, &out_received)); ULONG ev2_finalrefcount = ev2->Release(); - EXPECT_EQ(0, ev2_finalrefcount); + EXPECT_EQ(0u, ev2_finalrefcount); ULONG ev_finalrefcount = ev->Release(); - EXPECT_EQ(0, ev_finalrefcount); + EXPECT_EQ(0u, ev_finalrefcount); } } // namespace win diff --git a/base/win/event_trace_consumer_unittest.cc b/base/win/event_trace_consumer_unittest.cc index ecbf238..b159b93 100644 --- a/base/win/event_trace_consumer_unittest.cc +++ b/base/win/event_trace_consumer_unittest.cc @@ -209,7 +209,8 @@ TEST_F(EtwTraceConsumerRealtimeTest, ConsumerReturnsWhenSessionClosed) { ASSERT_HRESULT_SUCCEEDED(StartConsumerThread()); // Wait around for the consumer_ thread a bit. - ASSERT_EQ(WAIT_TIMEOUT, ::WaitForSingleObject(consumer_thread_.Get(), 50)); + ASSERT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), + ::WaitForSingleObject(consumer_thread_.Get(), 50)); ASSERT_HRESULT_SUCCEEDED(controller.Stop(NULL)); // The consumer_ returns success on session stop. @@ -237,14 +238,14 @@ TEST_F(EtwTraceConsumerRealtimeTest, ConsumeEvent) { test_provider_, TRACE_LEVEL_VERBOSE, 0xFFFFFFFF)); EtwTraceProvider provider(test_provider_); - ASSERT_EQ(ERROR_SUCCESS, provider.Register()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), provider.Register()); // Start the consumer_. ASSERT_HRESULT_SUCCEEDED(StartConsumerThread()); - ASSERT_EQ(0, TestConsumer::events_.size()); + ASSERT_EQ(0u, TestConsumer::events_.size()); EtwMofEvent<1> event(kTestEventType, 1, TRACE_LEVEL_ERROR); - EXPECT_EQ(ERROR_SUCCESS, provider.Log(&event.header)); + EXPECT_EQ(static_cast<DWORD>(ERROR_SUCCESS), provider.Log(&event.header)); EXPECT_EQ(WAIT_OBJECT_0, ::WaitForSingleObject(TestConsumer::sank_event_.Get(), INFINITE)); ASSERT_HRESULT_SUCCEEDED(controller.Stop(NULL)); @@ -294,9 +295,9 @@ class EtwTraceConsumerDataTest: public EtwTraceConsumerBaseTest { EtwTraceProvider provider(test_provider_); // Then register our provider, means we get a session handle immediately. - EXPECT_EQ(ERROR_SUCCESS, provider.Register()); + EXPECT_EQ(static_cast<DWORD>(ERROR_SUCCESS), provider.Register()); // Trace the event, it goes to the temp file. - EXPECT_EQ(ERROR_SUCCESS, provider.Log(header)); + EXPECT_EQ(static_cast<DWORD>(ERROR_SUCCESS), provider.Log(header)); EXPECT_HRESULT_SUCCEEDED(controller.DisableProvider(test_provider_)); EXPECT_HRESULT_SUCCEEDED(provider.Unregister()); EXPECT_HRESULT_SUCCEEDED(controller.Flush(NULL)); diff --git a/base/win/event_trace_controller_unittest.cc b/base/win/event_trace_controller_unittest.cc index c947ed7..c128253 100644 --- a/base/win/event_trace_controller_unittest.cc +++ b/base/win/event_trace_controller_unittest.cc @@ -62,25 +62,25 @@ TEST(EtwTracePropertiesTest, Initialization) { EXPECT_EQ(0u, p->Wnode.HistoricalContext); EXPECT_TRUE(kGuidNull == p->Wnode.Guid); - EXPECT_EQ(0, p->Wnode.ClientContext); - EXPECT_EQ(WNODE_FLAG_TRACED_GUID, p->Wnode.Flags); - - EXPECT_EQ(0, p->BufferSize); - EXPECT_EQ(0, p->MinimumBuffers); - EXPECT_EQ(0, p->MaximumBuffers); - EXPECT_EQ(0, p->MaximumFileSize); - EXPECT_EQ(0, p->LogFileMode); - EXPECT_EQ(0, p->FlushTimer); - EXPECT_EQ(0, p->EnableFlags); + EXPECT_EQ(0u, p->Wnode.ClientContext); + EXPECT_EQ(static_cast<ULONG>(WNODE_FLAG_TRACED_GUID), p->Wnode.Flags); + + EXPECT_EQ(0u, p->BufferSize); + EXPECT_EQ(0u, p->MinimumBuffers); + EXPECT_EQ(0u, p->MaximumBuffers); + EXPECT_EQ(0u, p->MaximumFileSize); + EXPECT_EQ(0u, p->LogFileMode); + EXPECT_EQ(0u, p->FlushTimer); + EXPECT_EQ(0u, p->EnableFlags); EXPECT_EQ(0, p->AgeLimit); - EXPECT_EQ(0, p->NumberOfBuffers); - EXPECT_EQ(0, p->FreeBuffers); - EXPECT_EQ(0, p->EventsLost); - EXPECT_EQ(0, p->BuffersWritten); - EXPECT_EQ(0, p->LogBuffersLost); - EXPECT_EQ(0, p->RealTimeBuffersLost); - EXPECT_EQ(0, p->LoggerThreadId); + EXPECT_EQ(0u, p->NumberOfBuffers); + EXPECT_EQ(0u, p->FreeBuffers); + EXPECT_EQ(0u, p->EventsLost); + EXPECT_EQ(0u, p->BuffersWritten); + EXPECT_EQ(0u, p->LogBuffersLost); + EXPECT_EQ(0u, p->RealTimeBuffersLost); + EXPECT_EQ(0u, p->LoggerThreadId); EXPECT_NE(0u, p->LogFileNameOffset); EXPECT_NE(0u, p->LoggerNameOffset); } @@ -133,7 +133,7 @@ class EtwTraceControllerTest : public testing::Test { TEST_F(EtwTraceControllerTest, Initialize) { EtwTraceController controller; - EXPECT_EQ(NULL, controller.session()); + EXPECT_EQ(0u, controller.session()); EXPECT_STREQ(L"", controller.session_name()); } @@ -148,11 +148,11 @@ TEST_F(EtwTraceControllerTest, StartRealTimeSession) { return; } - EXPECT_TRUE(NULL != controller.session()); + EXPECT_NE(0u, controller.session()); EXPECT_STREQ(session_name_.c_str(), controller.session_name()); EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); - EXPECT_EQ(NULL, controller.session()); + EXPECT_EQ(0u, controller.session()); EXPECT_STREQ(L"", controller.session_name()); } @@ -171,11 +171,11 @@ TEST_F(EtwTraceControllerTest, StartFileSession) { return; } - EXPECT_TRUE(NULL != controller.session()); + EXPECT_NE(0u, controller.session()); EXPECT_STREQ(session_name_.c_str(), controller.session_name()); EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); - EXPECT_EQ(NULL, controller.session()); + EXPECT_EQ(0u, controller.session()); EXPECT_STREQ(L"", controller.session_name()); base::DeleteFile(temp, false); } @@ -184,8 +184,8 @@ TEST_F(EtwTraceControllerTest, StartFileSession) { TEST_F(EtwTraceControllerTest, DISABLED_EnableDisable) { TestingProvider provider(test_provider_); - EXPECT_EQ(ERROR_SUCCESS, provider.Register()); - EXPECT_EQ(NULL, provider.session_handle()); + EXPECT_EQ(static_cast<DWORD>(ERROR_SUCCESS), provider.Register()); + EXPECT_EQ(0u, provider.session_handle()); EtwTraceController controller; HRESULT hr = controller.StartRealtimeSession(session_name_.c_str(), @@ -208,9 +208,9 @@ TEST_F(EtwTraceControllerTest, DISABLED_EnableDisable) { provider.WaitForCallback(); EXPECT_EQ(0, provider.enable_level()); - EXPECT_EQ(0, provider.enable_flags()); + EXPECT_EQ(0u, provider.enable_flags()); - EXPECT_EQ(ERROR_SUCCESS, provider.Unregister()); + EXPECT_EQ(static_cast<DWORD>(ERROR_SUCCESS), provider.Unregister()); // Enable the provider again, before registering. EXPECT_HRESULT_SUCCEEDED(controller.EnableProvider(test_provider_, @@ -218,7 +218,7 @@ TEST_F(EtwTraceControllerTest, DISABLED_EnableDisable) { // Register the provider again, the settings above // should take immediate effect. - EXPECT_EQ(ERROR_SUCCESS, provider.Register()); + EXPECT_EQ(static_cast<DWORD>(ERROR_SUCCESS), provider.Register()); EXPECT_EQ(TRACE_LEVEL_VERBOSE, provider.enable_level()); EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); @@ -235,7 +235,7 @@ TEST_F(EtwTraceControllerTest, DISABLED_EnableDisable) { // Session should have wound down. EXPECT_EQ(0, provider.enable_level()); - EXPECT_EQ(0, provider.enable_flags()); + EXPECT_EQ(0u, provider.enable_flags()); } } diff --git a/base/win/event_trace_provider.h b/base/win/event_trace_provider.h index a87cb9c..0775faf 100644 --- a/base/win/event_trace_provider.h +++ b/base/win/event_trace_provider.h @@ -67,7 +67,7 @@ template <size_t N> class EtwMofEvent: public EtwMofEventBase<N> { header.Flags = WNODE_FLAG_TRACED_GUID | WNODE_FLAG_USE_MOF_PTR; } - void SetField(int field, size_t size, const void *data) { + void SetField(size_t field, size_t size, const void* data) { // DCHECK(field < N); if ((field < N) && (size <= std::numeric_limits<uint32_t>::max())) { fields[field].DataPtr = reinterpret_cast<ULONG64>(data); diff --git a/base/win/event_trace_provider_unittest.cc b/base/win/event_trace_provider_unittest.cc index 55b5ae6..7d57773 100644 --- a/base/win/event_trace_provider_unittest.cc +++ b/base/win/event_trace_provider_unittest.cc @@ -31,10 +31,10 @@ TEST(EtwTraceProviderTest, ToleratesPreCreateInvocations) { char buf[sizeof(EtwTraceProvider)] = {0}; EtwTraceProvider& provider = reinterpret_cast<EtwTraceProvider&>(buf); - EXPECT_EQ(NULL, provider.registration_handle()); - EXPECT_EQ(NULL, provider.session_handle()); - EXPECT_EQ(0, provider.enable_flags()); - EXPECT_EQ(0, provider.enable_level()); + EXPECT_EQ(0u, provider.registration_handle()); + EXPECT_EQ(0u, provider.session_handle()); + EXPECT_EQ(0u, provider.enable_flags()); + EXPECT_EQ(0u, provider.enable_level()); EXPECT_FALSE(provider.ShouldLog(TRACE_LEVEL_FATAL, 0xfffffff)); @@ -51,16 +51,16 @@ TEST(EtwTraceProviderTest, ToleratesPreCreateInvocations) { new (buf) EtwTraceProvider(kTestProvider); // Registration is now safe. - EXPECT_EQ(ERROR_SUCCESS, provider.Register()); + EXPECT_EQ(static_cast<ULONG>(ERROR_SUCCESS), provider.Register()); // Destruct the instance, this should unregister it. provider.EtwTraceProvider::~EtwTraceProvider(); // And post-destruction, all of the above should still be safe. - EXPECT_EQ(NULL, provider.registration_handle()); - EXPECT_EQ(NULL, provider.session_handle()); - EXPECT_EQ(0, provider.enable_flags()); - EXPECT_EQ(0, provider.enable_level()); + EXPECT_EQ(0u, provider.registration_handle()); + EXPECT_EQ(0u, provider.session_handle()); + EXPECT_EQ(0u, provider.enable_flags()); + EXPECT_EQ(0u, provider.enable_level()); EXPECT_FALSE(provider.ShouldLog(TRACE_LEVEL_FATAL, 0xfffffff)); @@ -73,19 +73,19 @@ TEST(EtwTraceProviderTest, ToleratesPreCreateInvocations) { TEST(EtwTraceProviderTest, Initialize) { EtwTraceProvider provider(kTestProvider); - EXPECT_EQ(NULL, provider.registration_handle()); - EXPECT_EQ(NULL, provider.session_handle()); - EXPECT_EQ(0, provider.enable_flags()); - EXPECT_EQ(0, provider.enable_level()); + EXPECT_EQ(0u, provider.registration_handle()); + EXPECT_EQ(0u, provider.session_handle()); + EXPECT_EQ(0u, provider.enable_flags()); + EXPECT_EQ(0u, provider.enable_level()); } TEST(EtwTraceProviderTest, Register) { EtwTraceProvider provider(kTestProvider); - ASSERT_EQ(ERROR_SUCCESS, provider.Register()); - EXPECT_NE(NULL, provider.registration_handle()); - ASSERT_EQ(ERROR_SUCCESS, provider.Unregister()); - EXPECT_EQ(NULL, provider.registration_handle()); + ASSERT_EQ(static_cast<ULONG>(ERROR_SUCCESS), provider.Register()); + EXPECT_NE(0u, provider.registration_handle()); + ASSERT_EQ(static_cast<ULONG>(ERROR_SUCCESS), provider.Unregister()); + EXPECT_EQ(0u, provider.registration_handle()); } TEST(EtwTraceProviderTest, RegisterWithNoNameFails) { @@ -97,14 +97,14 @@ TEST(EtwTraceProviderTest, RegisterWithNoNameFails) { TEST(EtwTraceProviderTest, Enable) { EtwTraceProvider provider(kTestProvider); - ASSERT_EQ(ERROR_SUCCESS, provider.Register()); - EXPECT_NE(NULL, provider.registration_handle()); + ASSERT_EQ(static_cast<ULONG>(ERROR_SUCCESS), provider.Register()); + EXPECT_NE(0u, provider.registration_handle()); // No session so far. - EXPECT_EQ(NULL, provider.session_handle()); - EXPECT_EQ(0, provider.enable_flags()); - EXPECT_EQ(0, provider.enable_level()); + EXPECT_EQ(0u, provider.session_handle()); + EXPECT_EQ(0u, provider.enable_flags()); + EXPECT_EQ(0u, provider.enable_level()); - ASSERT_EQ(ERROR_SUCCESS, provider.Unregister()); - EXPECT_EQ(NULL, provider.registration_handle()); + ASSERT_EQ(static_cast<ULONG>(ERROR_SUCCESS), provider.Unregister()); + EXPECT_EQ(0u, provider.registration_handle()); } diff --git a/base/win/iunknown_impl_unittest.cc b/base/win/iunknown_impl_unittest.cc index 874a43a..c6c3539 100644 --- a/base/win/iunknown_impl_unittest.cc +++ b/base/win/iunknown_impl_unittest.cc @@ -30,8 +30,8 @@ TEST(IUnknownImplTest, IUnknownImpl) { EXPECT_EQ(1, TestIUnknownImplSubclass::instance_count); - EXPECT_EQ(1, u->AddRef()); - EXPECT_EQ(1, u->AddRef()); + EXPECT_EQ(1u, u->AddRef()); + EXPECT_EQ(1u, u->AddRef()); IUnknown* other = NULL; EXPECT_EQ(E_NOINTERFACE, u->QueryInterface( @@ -40,8 +40,8 @@ TEST(IUnknownImplTest, IUnknownImpl) { IID_IUnknown, reinterpret_cast<void**>(&other))); other->Release(); - EXPECT_EQ(1, u->Release()); - EXPECT_EQ(0, u->Release()); + EXPECT_EQ(1u, u->Release()); + EXPECT_EQ(0u, u->Release()); EXPECT_EQ(0, TestIUnknownImplSubclass::instance_count); } diff --git a/base/win/registry_unittest.cc b/base/win/registry_unittest.cc index 2257663..0b87023 100644 --- a/base/win/registry_unittest.cc +++ b/base/win/registry_unittest.cc @@ -167,7 +167,7 @@ TEST_F(RegistryTest, TruncatedCharTest) { const wchar_t kName[] = L"name"; // kData size is not a multiple of sizeof(wchar_t). const uint8 kData[] = { 1, 2, 3, 4, 5 }; - EXPECT_EQ(5, arraysize(kData)); + EXPECT_EQ(5u, arraysize(kData)); ASSERT_EQ(ERROR_SUCCESS, key.WriteValue(kName, kData, arraysize(kData), REG_BINARY)); diff --git a/base/win/scoped_bstr_unittest.cc b/base/win/scoped_bstr_unittest.cc index 5f6f7df..9a289ff 100644 --- a/base/win/scoped_bstr_unittest.cc +++ b/base/win/scoped_bstr_unittest.cc @@ -18,8 +18,8 @@ size_t test2_len = arraysize(kTestString2) - 1; void DumbBstrTests() { ScopedBstr b; EXPECT_TRUE(b == NULL); - EXPECT_EQ(0, b.Length()); - EXPECT_EQ(0, b.ByteLength()); + EXPECT_EQ(0u, b.Length()); + EXPECT_EQ(0u, b.ByteLength()); b.Reset(NULL); EXPECT_TRUE(b == NULL); EXPECT_TRUE(b.Release() == NULL); @@ -40,7 +40,7 @@ void BasicBstrTests() { ScopedBstr b2; b1.Swap(b2); EXPECT_EQ(test1_len, b2.Length()); - EXPECT_EQ(0, b1.Length()); + EXPECT_EQ(0u, b1.Length()); EXPECT_EQ(0, lstrcmp(b2, kTestString1)); BSTR tmp = b2.Release(); EXPECT_TRUE(tmp != NULL); @@ -52,13 +52,13 @@ void BasicBstrTests() { EXPECT_TRUE(b2 != NULL); b2.Reset(); EXPECT_TRUE(b2.AllocateBytes(100) != NULL); - EXPECT_EQ(100, b2.ByteLength()); + EXPECT_EQ(100u, b2.ByteLength()); EXPECT_EQ(100 / sizeof(kTestString1[0]), b2.Length()); lstrcpy(static_cast<BSTR>(b2), kTestString1); - EXPECT_EQ(test1_len, lstrlen(b2)); + EXPECT_EQ(test1_len, static_cast<size_t>(lstrlen(b2))); EXPECT_EQ(100 / sizeof(kTestString1[0]), b2.Length()); b2.SetByteLen(lstrlen(b2) * sizeof(kTestString2[0])); - EXPECT_EQ(b2.Length(), lstrlen(b2)); + EXPECT_EQ(b2.Length(), static_cast<size_t>(lstrlen(b2))); EXPECT_TRUE(b1.Allocate(kTestString2) != NULL); EXPECT_EQ(test2_len, b1.Length()); diff --git a/base/win/scoped_process_information_unittest.cc b/base/win/scoped_process_information_unittest.cc index 614504d..799b273 100644 --- a/base/win/scoped_process_information_unittest.cc +++ b/base/win/scoped_process_information_unittest.cc @@ -80,7 +80,7 @@ TEST_F(ScopedProcessInformationTest, TakeProcess) { HANDLE process = process_info.TakeProcessHandle(); EXPECT_EQ(kProcessHandle, process); EXPECT_EQ(NULL, process_info.process_handle()); - EXPECT_EQ(0, process_info.process_id()); + EXPECT_EQ(0u, process_info.process_id()); EXPECT_TRUE(process_info.IsValid()); process_info.Take(); } @@ -92,7 +92,7 @@ TEST_F(ScopedProcessInformationTest, TakeThread) { HANDLE thread = process_info.TakeThreadHandle(); EXPECT_EQ(kThreadHandle, thread); EXPECT_EQ(NULL, process_info.thread_handle()); - EXPECT_EQ(0, process_info.thread_id()); + EXPECT_EQ(0u, process_info.thread_id()); EXPECT_TRUE(process_info.IsValid()); process_info.Take(); } diff --git a/base/win/scoped_variant_unittest.cc b/base/win/scoped_variant_unittest.cc index d530d5b..48f08bb 100644 --- a/base/win/scoped_variant_unittest.cc +++ b/base/win/scoped_variant_unittest.cc @@ -144,19 +144,19 @@ TEST(ScopedVariantTest, ScopedVariant) { var.Set(static_cast<uint8>(123)); EXPECT_EQ(VT_UI1, var.type()); - EXPECT_EQ(123, V_UI1(var.ptr())); + EXPECT_EQ(123u, V_UI1(var.ptr())); var.Set(static_cast<unsigned short>(123)); EXPECT_EQ(VT_UI2, var.type()); - EXPECT_EQ(123, V_UI2(var.ptr())); + EXPECT_EQ(123u, V_UI2(var.ptr())); var.Set(static_cast<uint32>(123)); EXPECT_EQ(VT_UI4, var.type()); - EXPECT_EQ(123, V_UI4(var.ptr())); + EXPECT_EQ(123u, V_UI4(var.ptr())); var.Set(static_cast<uint64>(123)); EXPECT_EQ(VT_UI8, var.type()); - EXPECT_EQ(123, V_UI8(var.ptr())); + EXPECT_EQ(123u, V_UI8(var.ptr())); var.Set(123.123f); EXPECT_EQ(VT_R4, var.type()); diff --git a/base/win/startup_information.h b/base/win/startup_information.h index 3f18ee5..66c287f 100644 --- a/base/win/startup_information.h +++ b/base/win/startup_information.h @@ -31,7 +31,7 @@ class BASE_EXPORT StartupInformation { size_t size); LPSTARTUPINFOW startup_info() { return &startup_info_.StartupInfo; } - const LPSTARTUPINFOW startup_info() const { + LPSTARTUPINFOW startup_info() const { return const_cast<const LPSTARTUPINFOW>(&startup_info_.StartupInfo); } diff --git a/build/common.gypi b/build/common.gypi index 46ab6bf4..5b207f5 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -5828,6 +5828,13 @@ ['clang==1', { 'VCCLCompilerTool': { 'AdditionalOptions': [ + # Don't warn about unused function parameters. + # (This is also used on other platforms.) + '-Wno-unused-parameter', + # Don't warn about the "struct foo f = {0};" initialization + # pattern. + '-Wno-missing-field-initializers', + # Many files use intrinsics without including this header. # TODO(hans): Fix those files, or move this to sub-GYPs. '/FIIntrin.h', diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index a4ff2ed..10148bd 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -779,16 +779,6 @@ config("default_warnings") { ] } } else { - # Common GCC warning setup. - cflags += [ - # Enables. - "-Wendif-labels", # Weird old-style text after an #endif. - - # Disables. - "-Wno-missing-field-initializers", # "struct foo f = {0};" - "-Wno-unused-parameter", # Unused function parameters. - ] - if (treat_warnings_as_errors) { cflags += [ "-Werror" ] } @@ -830,6 +820,18 @@ config("default_warnings") { } } + # Common Clang and GCC warning setup. + if (!is_win || is_clang) { + cflags += [ + # Enables. + "-Wendif-labels", # Weird old-style text after an #endif. + + # Disables. + "-Wno-missing-field-initializers", # "struct foo f = {0};" + "-Wno-unused-parameter", # Unused function parameters. + ] + } + if (is_clang) { cflags += [ # This warns on using ints as initializers for floats in diff --git a/chrome/browser/policy/policy_path_parser_win.cc b/chrome/browser/policy/policy_path_parser_win.cc index 3fa8a99..2e0c197 100644 --- a/chrome/browser/policy/policy_path_parser_win.cc +++ b/chrome/browser/policy/policy_path_parser_win.cc @@ -77,7 +77,7 @@ base::FilePath::StringType ExpandPathVariables( result = result.substr(1, result.length() - 2); } // First translate all path variables we recognize. - for (int i = 0; i < arraysize(win_folder_mapping); ++i) { + for (size_t i = 0; i < arraysize(win_folder_mapping); ++i) { size_t position = result.find(win_folder_mapping[i].name); if (position != std::wstring::npos) { WCHAR path[MAX_PATH]; diff --git a/chrome/installer/util/app_command.cc b/chrome/installer/util/app_command.cc index 0d6be90..66242b5 100644 --- a/chrome/installer/util/app_command.cc +++ b/chrome/installer/util/app_command.cc @@ -57,7 +57,7 @@ bool AppCommand::Initialize(const base::win::RegKey& key) { command_line_.swap(cmd_line); - for (int i = 0; i < arraysize(kNameBoolVars); ++i) { + for (size_t i = 0; i < arraysize(kNameBoolVars); ++i) { DWORD value = 0; // Set default to false. // Note: ReadValueDW only modifies out param on success. key.ReadValueDW(kNameBoolVars[i].name, &value); @@ -83,7 +83,7 @@ void AppCommand::AddWorkItems(HKEY predefined_root, true) ->set_log_message("setting AppCommand CommandLine registry value"); - for (int i = 0; i < arraysize(kNameBoolVars); ++i) { + for (size_t i = 0; i < arraysize(kNameBoolVars); ++i) { const wchar_t* var_name = kNameBoolVars[i].name; bool var_data = this->*(kNameBoolVars[i].data); diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index d6175e5..90c868c 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc @@ -521,7 +521,7 @@ void InstallerState::GetExistingExeVersions( installer::kChromeOldExe, }; - for (int i = 0; i < arraysize(kChromeFilenames); ++i) { + for (size_t i = 0; i < arraysize(kChromeFilenames); ++i) { base::FilePath chrome_exe(target_path().Append(kChromeFilenames[i])); scoped_ptr<FileVersionInfo> file_version_info( FileVersionInfo::CreateFileVersionInfo(chrome_exe)); diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc index 616c793..77aff7b 100644 --- a/chrome_elf/blacklist/blacklist.cc +++ b/chrome_elf/blacklist/blacklist.cc @@ -243,7 +243,9 @@ bool IsBlacklistInitialized() { } int GetBlacklistIndex(const wchar_t* dll_name) { - for (int i = 0; i < kTroublesomeDllsMaxCount && g_troublesome_dlls[i]; ++i) { + for (int i = 0; + i < static_cast<int>(kTroublesomeDllsMaxCount) && g_troublesome_dlls[i]; + ++i) { if (_wcsicmp(dll_name, g_troublesome_dlls[i]) == 0) return i; } @@ -253,7 +255,7 @@ int GetBlacklistIndex(const wchar_t* dll_name) { bool AddDllToBlacklist(const wchar_t* dll_name) { int blacklist_size = BlacklistSize(); // We need to leave one space at the end for the null pointer. - if (blacklist_size + 1 >= kTroublesomeDllsMaxCount) + if (blacklist_size + 1 >= static_cast<int>(kTroublesomeDllsMaxCount)) return false; for (int i = 0; i < blacklist_size; ++i) { if (!_wcsicmp(g_troublesome_dlls[i], dll_name)) diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc index 9032258..c7fc3a5 100644 --- a/cloud_print/virtual_driver/win/install/setup.cc +++ b/cloud_print/virtual_driver/win/install/setup.cc @@ -193,7 +193,7 @@ UINT CALLBACK CabinetCallback(PVOID data, if (notification == SPFILENOTIFY_FILEINCABINET) { FILE_IN_CABINET_INFO* info = reinterpret_cast<FILE_IN_CABINET_INFO*>(param1); - for (int i = 0; i < arraysize(kDependencyList); i++) { + for (size_t i = 0; i < arraysize(kDependencyList); i++) { base::FilePath base_name(info->NameInCabinet); base_name = base_name.BaseName(); if (base::FilePath::CompareEqualIgnoreCase(base_name.value().c_str(), diff --git a/components/crash/content/app/hard_error_handler_win.cc b/components/crash/content/app/hard_error_handler_win.cc index a310666..21f2436 100644 --- a/components/crash/content/app/hard_error_handler_win.cc +++ b/components/crash/content/app/hard_error_handler_win.cc @@ -33,8 +33,9 @@ DWORD FacilityFromException(DWORD exception_code) { // This is not a generic function. It only works with some |nt_status| values. // Check the strings here http://msdn.microsoft.com/en-us/library/cc704588.aspx // before attempting to use this function. -void RaiseHardErrorMsg(long nt_status, const std::string& p1, - const std::string& p2) { +void RaiseHardErrorMsg(DWORD nt_status, + const std::string& p1, + const std::string& p2) { // If headless just exit silently. if (GetCrashReporterClient()->IsRunningUnattended()) return; @@ -95,7 +96,7 @@ bool HardErrorHandler(EXCEPTION_POINTERS* ex_info) { if (!ex_info->ExceptionRecord) return false; - long exception = ex_info->ExceptionRecord->ExceptionCode; + DWORD exception = ex_info->ExceptionRecord->ExceptionCode; if (exception == kExceptionModuleNotFound) { ModuleNotFoundHardError(ex_info->ExceptionRecord); return true; diff --git a/content/browser/accessibility/accessibility_tree_formatter_win.cc b/content/browser/accessibility/accessibility_tree_formatter_win.cc index c7ef471..6277f43 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_win.cc +++ b/content/browser/accessibility/accessibility_tree_formatter_win.cc @@ -298,8 +298,7 @@ base::string16 AccessibilityTreeFormatter::ToString( dict.GetString("role", &role_value); WriteAttribute(true, base::UTF16ToUTF8(role_value), &line); - for (int i = 0; i < arraysize(ALL_ATTRIBUTES); i++) { - const char* attribute_name = ALL_ATTRIBUTES[i]; + for (const char* attribute_name : ALL_ATTRIBUTES) { const base::Value* value; if (!dict.Get(attribute_name, &value)) continue; diff --git a/content/browser/accessibility/accessibility_win_browsertest.cc b/content/browser/accessibility/accessibility_win_browsertest.cc index 373ef0ed..a28a06b 100644 --- a/content/browser/accessibility/accessibility_win_browsertest.cc +++ b/content/browser/accessibility/accessibility_win_browsertest.cc @@ -126,7 +126,7 @@ void AccessibilityWinBrowserTest::SetUpInputField( base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); std::vector<base::win::ScopedVariant> document_children = GetAllAccessibleChildren(document.get()); - ASSERT_EQ(1, document_children.size()); + ASSERT_EQ(1u, document_children.size()); base::win::ScopedComPtr<IAccessible2> form; HRESULT hr = QueryIAccessible2(GetAccessibleFromVariant( @@ -134,7 +134,7 @@ void AccessibilityWinBrowserTest::SetUpInputField( ASSERT_EQ(S_OK, hr); std::vector<base::win::ScopedVariant> form_children = GetAllAccessibleChildren(form.get()); - ASSERT_EQ(2, form_children.size()); + ASSERT_EQ(2u, form_children.size()); // Find the input text field. base::win::ScopedComPtr<IAccessible2> input; @@ -178,7 +178,7 @@ void AccessibilityWinBrowserTest::SetUpTextareaField( base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); std::vector<base::win::ScopedVariant> document_children = GetAllAccessibleChildren(document.get()); - ASSERT_EQ(1, document_children.size()); + ASSERT_EQ(1u, document_children.size()); base::win::ScopedComPtr<IAccessible2> section; HRESULT hr = QueryIAccessible2(GetAccessibleFromVariant( @@ -186,7 +186,7 @@ void AccessibilityWinBrowserTest::SetUpTextareaField( ASSERT_EQ(S_OK, hr); std::vector<base::win::ScopedVariant> section_children = GetAllAccessibleChildren(section.get()); - ASSERT_EQ(1, section_children.size()); + ASSERT_EQ(1u, section_children.size()); // Find the textarea text field. base::win::ScopedComPtr<IAccessible2> textarea; @@ -905,7 +905,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, &unique_id, &node_type); ASSERT_EQ(S_OK, hr); EXPECT_EQ(NODETYPE_DOCUMENT, node_type); - EXPECT_EQ(1, num_children); + EXPECT_EQ(1u, num_children); node_name.Reset(); node_value.Reset(); @@ -919,7 +919,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, ASSERT_EQ(S_OK, hr); EXPECT_EQ(L"body", std::wstring(node_name, node_name.Length())); EXPECT_EQ(NODETYPE_ELEMENT, node_type); - EXPECT_EQ(1, num_children); + EXPECT_EQ(1u, num_children); node_name.Reset(); node_value.Reset(); @@ -933,7 +933,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, ASSERT_EQ(S_OK, hr); EXPECT_EQ(L"input", std::wstring(node_name, node_name.Length())); EXPECT_EQ(NODETYPE_ELEMENT, node_type); - EXPECT_EQ(0, num_children); + EXPECT_EQ(0u, num_children); } IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestRoleGroup) { diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index 2e85e25..89cdd54 100644 --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc @@ -484,7 +484,7 @@ TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { const std::string text1_name = "One two three."; const std::string text2_name = " Four five six."; - const size_t text_name_len = text1_name.length() + text2_name.length(); + const long text_name_len = text1_name.length() + text2_name.length(); ui::AXNodeData text1; text1.id = 11; @@ -567,7 +567,7 @@ TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { const base::string16 embed(1, BrowserAccessibilityWin::kEmbeddedCharacter); const base::string16 root_hypertext = text1_name + embed + text2_name + embed + embed + embed; - const size_t root_hypertext_len = root_hypertext.length(); + const long root_hypertext_len = root_hypertext.length(); ui::AXNodeData text1; text1.id = 11; diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_win.cc b/content/browser/gamepad/gamepad_platform_data_fetcher_win.cc index 4882efb..f944ead 100644 --- a/content/browser/gamepad/gamepad_platform_data_fetcher_win.cc +++ b/content/browser/gamepad/gamepad_platform_data_fetcher_win.cc @@ -34,7 +34,7 @@ float NormalizeXInputAxis(SHORT value) { return ((value + 32768.f) / 32767.5f) - 1.f; } -const WebUChar* const GamepadSubTypeName(BYTE sub_type) { +const WebUChar* GamepadSubTypeName(BYTE sub_type) { switch (sub_type) { case kDeviceSubTypeGamepad: return L"GAMEPAD"; case kDeviceSubTypeWheel: return L"WHEEL"; diff --git a/content/browser/gamepad/raw_input_data_fetcher_win.cc b/content/browser/gamepad/raw_input_data_fetcher_win.cc index 8b3b34f..670a022 100644 --- a/content/browser/gamepad/raw_input_data_fetcher_win.cc +++ b/content/browser/gamepad/raw_input_data_fetcher_win.cc @@ -58,9 +58,9 @@ void RawInputDataFetcher::WillDestroyCurrentMessageLoop() { } RAWINPUTDEVICE* RawInputDataFetcher::GetRawInputDevices(DWORD flags) { - int usage_count = arraysize(DeviceUsages); + size_t usage_count = arraysize(DeviceUsages); scoped_ptr<RAWINPUTDEVICE[]> devices(new RAWINPUTDEVICE[usage_count]); - for (int i = 0; i < usage_count; ++i) { + for (size_t i = 0; i < usage_count; ++i) { devices[i].dwFlags = flags; devices[i].usUsagePage = 1; devices[i].usUsage = DeviceUsages[i]; @@ -200,8 +200,8 @@ RawGamepadInfo* RawInputDataFetcher::ParseGamepadInfo(HANDLE hDevice) { // Make sure this device is of a type that we want to observe. bool valid_type = false; - for (int i = 0; i < arraysize(DeviceUsages); ++i) { - if (device_info->hid.usUsage == DeviceUsages[i]) { + for (USHORT device_usage : DeviceUsages) { + if (device_info->hid.usUsage == device_usage) { valid_type = true; break; } @@ -389,8 +389,10 @@ void RawInputDataFetcher::UpdateGamepad( for (uint32_t j = 0; j < buttons_length; j++) { int32_t button_index = usages[j].Usage - 1; if (button_index >= 0 && - button_index < blink::WebGamepad::buttonsLengthCap) + button_index < + static_cast<int>(blink::WebGamepad::buttonsLengthCap)) { gamepad_info->buttons[button_index] = true; + } } } } diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.cc b/content/browser/renderer_host/legacy_render_widget_host_win.cc index bd0101d..9e23057 100644 --- a/content/browser/renderer_host/legacy_render_widget_host_win.cc +++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc @@ -166,7 +166,7 @@ LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message, return static_cast<LRESULT>(0L); } - if (OBJID_CLIENT != obj_id || !host_) + if (static_cast<DWORD>(OBJID_CLIENT) != obj_id || !host_) return static_cast<LRESULT>(0L); RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( diff --git a/content/browser/system_message_window_win.cc b/content/browser/system_message_window_win.cc index 08f44cb..36cc177 100644 --- a/content/browser/system_message_window_win.cc +++ b/content/browser/system_message_window_win.cc @@ -45,7 +45,7 @@ class SystemMessageWindowWin::DeviceNotifications { filter.dbcc_size = sizeof(filter); filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; bool core_audio_support = media::CoreAudioUtil::IsSupported(); - for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) { + for (size_t i = 0; i < arraysize(kDeviceCategoryMap); ++i) { // If CoreAudio is supported, AudioDeviceListenerWin will // take care of monitoring audio devices. if (core_audio_support && @@ -63,7 +63,7 @@ class SystemMessageWindowWin::DeviceNotifications { } void Unregister() { - for (int i = 0; i < arraysize(notifications_); ++i) { + for (size_t i = 0; i < arraysize(notifications_); ++i) { if (notifications_[i]) { UnregisterDeviceNotification(notifications_[i]); notifications_[i] = NULL; @@ -122,7 +122,7 @@ LRESULT SystemMessageWindowWin::OnDeviceChange(UINT event_type, LPARAM data) { reinterpret_cast<DEV_BROADCAST_DEVICEINTERFACE*>(data); if (device_interface->dbcc_devicetype != DBT_DEVTYP_DEVICEINTERFACE) return TRUE; - for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) { + for (size_t i = 0; i < arraysize(kDeviceCategoryMap); ++i) { if (kDeviceCategoryMap[i].device_category == device_interface->dbcc_classguid) { device_type = kDeviceCategoryMap[i].device_type; diff --git a/content/browser/web_contents/aura/overscroll_window_delegate_unittest.cc b/content/browser/web_contents/aura/overscroll_window_delegate_unittest.cc index 13382a8..15c9f88 100644 --- a/content/browser/web_contents/aura/overscroll_window_delegate_unittest.cc +++ b/content/browser/web_contents/aura/overscroll_window_delegate_unittest.cc @@ -54,11 +54,9 @@ class OverscrollWindowDelegateTest : public aura::test::AuraTestBase, OverscrollMode current_mode() { return current_mode_; } - const float touch_start_threshold() { - return touch_start_threshold_; - } + float touch_start_threshold() { return touch_start_threshold_; } - const float touch_complete_threshold() { + float touch_complete_threshold() { return kTestWindowWidth * touch_complete_threshold_; } diff --git a/content/child/npapi/webplugin_delegate_impl_win.cc b/content/child/npapi/webplugin_delegate_impl_win.cc index 8dd3687..582fdf7 100644 --- a/content/child/npapi/webplugin_delegate_impl_win.cc +++ b/content/child/npapi/webplugin_delegate_impl_win.cc @@ -169,7 +169,7 @@ std::wstring GetKeyPath(HKEY key) { DWORD size = 0; DWORD result = 0; result = func(key, KeyNameInformation, 0, 0, &size); - if (result != STATUS_BUFFER_TOO_SMALL) + if (result != static_cast<DWORD>(STATUS_BUFFER_TOO_SMALL)) return L""; scoped_ptr<char[]> buffer(new char[size]); @@ -177,7 +177,7 @@ std::wstring GetKeyPath(HKEY key) { return L""; result = func(key, KeyNameInformation, buffer.get(), size, &size); - if (result != STATUS_SUCCESS) + if (result != static_cast<DWORD>(STATUS_SUCCESS)) return L""; KEY_NAME_INFORMATION* info = diff --git a/content/child/npapi/webplugin_ime_win.cc b/content/child/npapi/webplugin_ime_win.cc index 7ff6a5d..e095ee1 100644 --- a/content/child/npapi/webplugin_ime_win.cc +++ b/content/child/npapi/webplugin_ime_win.cc @@ -169,7 +169,7 @@ FARPROC WebPluginIMEWin::GetProcAddress(LPCSTR name) { reinterpret_cast<FARPROC>(ImmSetCandidateWindow) }, { "ImmSetOpenStatus", reinterpret_cast<FARPROC>(ImmSetOpenStatus) }, }; - for (int i = 0; i < arraysize(kImm32Functions); ++i) { + for (size_t i = 0; i < arraysize(kImm32Functions); ++i) { if (!lstrcmpiA(name, kImm32Functions[i].name)) return kImm32Functions[i].function; } diff --git a/content/common/cursors/webcursor.cc b/content/common/cursors/webcursor.cc index b2dfcdf..d610ceb 100644 --- a/content/common/cursors/webcursor.cc +++ b/content/common/cursors/webcursor.cc @@ -192,9 +192,9 @@ static WebCursorInfo::Type ToCursorType(HCURSOR cursor) { { LoadCursor(NULL, IDC_APPSTARTING), WebCursorInfo::TypeProgress }, { LoadCursor(NULL, IDC_NO), WebCursorInfo::TypeNotAllowed }, }; - for (int i = 0; i < arraysize(kStandardCursors); ++i) { - if (cursor == kStandardCursors[i].cursor) - return kStandardCursors[i].type; + for (const auto& kStandardCursor : kStandardCursors) { + if (cursor == kStandardCursor.cursor) + return kStandardCursor.type; } return WebCursorInfo::TypeCustom; } diff --git a/content/common/font_warmup_win_unittest.cc b/content/common/font_warmup_win_unittest.cc index 80eb9e5..c6ba7b1 100644 --- a/content/common/font_warmup_win_unittest.cc +++ b/content/common/font_warmup_win_unittest.cc @@ -256,9 +256,9 @@ TEST(GDIFontEmulationTest, CreateDeleteDCSuccess) { HDC hdc = CreateCompatibleDC(0); EXPECT_NE(hdc, nullptr); - EXPECT_EQ(GetEmulatedGdiHandleCountForTesting(), 1); + EXPECT_EQ(1u, GetEmulatedGdiHandleCountForTesting()); EXPECT_TRUE(DeleteDC(hdc)); - EXPECT_EQ(GetEmulatedGdiHandleCountForTesting(), 0); + EXPECT_EQ(0u, GetEmulatedGdiHandleCountForTesting()); } TEST(GDIFontEmulationTest, CreateUniqueDCSuccess) { @@ -274,9 +274,9 @@ TEST(GDIFontEmulationTest, CreateUniqueDCSuccess) { EXPECT_NE(hdc2, nullptr); EXPECT_NE(hdc1, hdc2); EXPECT_TRUE(DeleteDC(hdc2)); - EXPECT_EQ(GetEmulatedGdiHandleCountForTesting(), 1); + EXPECT_EQ(1u, GetEmulatedGdiHandleCountForTesting()); EXPECT_TRUE(DeleteDC(hdc1)); - EXPECT_EQ(GetEmulatedGdiHandleCountForTesting(), 0); + EXPECT_EQ(0u, GetEmulatedGdiHandleCountForTesting()); } TEST(GDIFontEmulationTest, CreateFontSuccess) { @@ -290,7 +290,7 @@ TEST(GDIFontEmulationTest, CreateFontSuccess) { HFONT font = CreateFontIndirectW(&logfont); EXPECT_NE(font, nullptr); EXPECT_TRUE(DeleteObject(font)); - EXPECT_EQ(GetEmulatedGdiHandleCountForTesting(), 0); + EXPECT_EQ(0u, GetEmulatedGdiHandleCountForTesting()); } TEST(GDIFontEmulationTest, CreateFontFailure) { diff --git a/content/common/sandbox_win.cc b/content/common/sandbox_win.cc index a3554a2..856d122 100644 --- a/content/common/sandbox_win.cc +++ b/content/common/sandbox_win.cc @@ -814,7 +814,7 @@ base::Process StartSandboxedProcess( delegate->PostSpawnTarget(target.process_handle()); - CHECK(ResumeThread(target.thread_handle()) != -1); + CHECK(ResumeThread(target.thread_handle()) != static_cast<DWORD>(-1)); return base::Process(target.TakeProcessHandle()); } diff --git a/crypto/symmetric_key_win.cc b/crypto/symmetric_key_win.cc index e2dc9b4..efc7fe4 100644 --- a/crypto/symmetric_key_win.cc +++ b/crypto/symmetric_key_win.cc @@ -51,7 +51,7 @@ bool ImportRawKey(HCRYPTPROV provider, ALG_ID alg, const void* key_data, size_t key_size, ScopedHCRYPTKEY* key) { - DCHECK_GT(key_size, 0); + DCHECK_GT(key_size, 0u); DWORD actual_size = static_cast<DWORD>(sizeof(PlaintextBlobHeader) + key_size); @@ -314,7 +314,7 @@ SymmetricKey::~SymmetricKey() { // static SymmetricKey* SymmetricKey::GenerateRandomKey(Algorithm algorithm, size_t key_size_in_bits) { - DCHECK_GE(key_size_in_bits, 8); + DCHECK_GE(key_size_in_bits, 8u); ScopedHCRYPTPROV provider; ScopedHCRYPTKEY key; @@ -412,7 +412,7 @@ SymmetricKey* SymmetricKey::DeriveKeyFromPassword(Algorithm algorithm, // 1. If dkLen > (2^32 - 1) * hLen, output "derived key too long" and stop. size_t dkLen = key_size_in_bits / 8; - DCHECK_GT(dkLen, 0); + DCHECK_GT(dkLen, 0u); if ((dkLen / hLen) > 0xFFFFFFFF) { DLOG(ERROR) << "Derived key too long."; @@ -423,7 +423,7 @@ SymmetricKey* SymmetricKey::DeriveKeyFromPassword(Algorithm algorithm, // rounding up, and let r be the number of octets in the last // block: size_t L = (dkLen + hLen - 1) / hLen; - DCHECK_GT(L, 0); + DCHECK_GT(L, 0u); size_t total_generated_size = L * hLen; std::vector<BYTE> generated_key(total_generated_size); diff --git a/media/base/user_input_monitor_win.cc b/media/base/user_input_monitor_win.cc index 3e172c4..19d27b7 100644 --- a/media/base/user_input_monitor_win.cc +++ b/media/base/user_input_monitor_win.cc @@ -180,7 +180,7 @@ LRESULT UserInputMonitorWinCore::OnInput(HRAWINPUT input_handle) { UINT size = 0; UINT result = GetRawInputData( input_handle, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); - if (result == -1) { + if (result == static_cast<UINT>(-1)) { PLOG(ERROR) << "GetRawInputData() failed"; return 0; } @@ -191,7 +191,7 @@ LRESULT UserInputMonitorWinCore::OnInput(HRAWINPUT input_handle) { RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); result = GetRawInputData( input_handle, RID_INPUT, buffer.get(), &size, sizeof(RAWINPUTHEADER)); - if (result == -1) { + if (result == static_cast<UINT>(-1)) { PLOG(ERROR) << "GetRawInputData() failed"; return 0; } diff --git a/media/capture/video/win/video_capture_device_factory_win.cc b/media/capture/video/win/video_capture_device_factory_win.cc index 5a626f8..1ff42d8 100644 --- a/media/capture/video/win/video_capture_device_factory_win.cc +++ b/media/capture/video/win/video_capture_device_factory_win.cc @@ -63,9 +63,9 @@ static bool LoadMediaFoundationDlls() { L"%WINDIR%\\system32\\mfreadwrite.dll", }; - for (int i = 0; i < arraysize(kMfDLLs); ++i) { + for (const wchar_t* kMfDLL : kMfDLLs) { wchar_t path[MAX_PATH] = {0}; - ExpandEnvironmentStringsW(kMfDLLs[i], path, arraysize(path)); + ExpandEnvironmentStringsW(kMfDLL, path, arraysize(path)); if (!LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) return false; } diff --git a/media/capture/video/win/video_capture_device_mf_win.cc b/media/capture/video/win/video_capture_device_mf_win.cc index 95595bd..77f54f8 100644 --- a/media/capture/video/win/video_capture_device_mf_win.cc +++ b/media/capture/video/win/video_capture_device_mf_win.cc @@ -171,9 +171,9 @@ bool VideoCaptureDeviceMFWin::FormatFromGuid(const GUID& guid, {MFVideoFormat_YV12, PIXEL_FORMAT_YV12}, }; - for (int i = 0; i < arraysize(kFormatMap); ++i) { - if (kFormatMap[i].guid == guid) { - *format = kFormatMap[i].format; + for (const auto& kFormat : kFormatMap) { + if (kFormat.guid == guid) { + *format = kFormat.format; return true; } } diff --git a/net/base/keygen_handler_win.cc b/net/base/keygen_handler_win.cc index 44365fa..e7f10d6 100644 --- a/net/base/keygen_handler_win.cc +++ b/net/base/keygen_handler_win.cc @@ -183,7 +183,7 @@ std::string KeygenHandler::GenKeyAndSignChallenge() { CRYPT_SILENT | CRYPT_NEWKEYSET)) break; - if (GetLastError() != NTE_BAD_KEYSET) { + if (GetLastError() != static_cast<DWORD>(NTE_BAD_KEYSET)) { LOG(ERROR) << "Keygen failed: Couldn't acquire a CryptoAPI provider " "context: " << GetLastError(); return std::string(); diff --git a/net/cert/test_root_certs_win.cc b/net/cert/test_root_certs_win.cc index a83ac04..36e7028 100644 --- a/net/cert/test_root_certs_win.cc +++ b/net/cert/test_root_certs_win.cc @@ -148,7 +148,7 @@ bool TestRootCerts::Add(X509Certificate* certificate) { CERT_STORE_ADD_NEW, NULL); if (!ok) { // If the certificate is already added, return successfully. - return GetLastError() == CRYPT_E_EXISTS; + return GetLastError() == static_cast<DWORD>(CRYPT_E_EXISTS); } empty_ = false; diff --git a/net/ssl/client_cert_store_win.cc b/net/ssl/client_cert_store_win.cc index c8b7501..1ebf02d 100644 --- a/net/ssl/client_cert_store_win.cc +++ b/net/ssl/client_cert_store_win.cc @@ -98,7 +98,7 @@ void GetClientCertsImpl(HCERTSTORE cert_store, &find_by_issuer_para, chain_context); if (!chain_context) { - if (GetLastError() != CRYPT_E_NOT_FOUND) + if (GetLastError() != static_cast<DWORD>(CRYPT_E_NOT_FOUND)) DPLOG(ERROR) << "CertFindChainInStore failed: "; break; } diff --git a/sandbox/win/src/crosscall_params.h b/sandbox/win/src/crosscall_params.h index a601fc7..c060c60 100644 --- a/sandbox/win/src/crosscall_params.h +++ b/sandbox/win/src/crosscall_params.h @@ -114,7 +114,7 @@ class CrossCallParams { } // Returns how many parameter this IPC call should have. - const uint32_t GetParamsCount() const { return params_count_; } + uint32_t GetParamsCount() const { return params_count_; } // Returns a pointer to the CrossCallReturn structure. CrossCallReturn* GetCallReturn() { @@ -122,9 +122,7 @@ class CrossCallParams { } // Returns TRUE if this call contains InOut parameters. - const bool IsInOut() const { - return (1 == is_in_out_); - } + bool IsInOut() const { return (1 == is_in_out_); } // Tells the CrossCall object if it contains InOut parameters. void SetIsInOut(bool value) { diff --git a/sandbox/win/src/handle_closer_test.cc b/sandbox/win/src/handle_closer_test.cc index 1cb2bb5..10ebe3b 100644 --- a/sandbox/win/src/handle_closer_test.cc +++ b/sandbox/win/src/handle_closer_test.cc @@ -86,8 +86,8 @@ SBOX_TESTS_COMMAND int CheckForFileHandles(int argc, wchar_t **argv) { case BEFORE_INIT: // Create a unique marker file that is open while the test is running. // The handles leak, but it will be closed by the test or on exit. - for (int i = 0; i < arraysize(kFileExtensions); ++i) - CHECK_NE(GetMarkerFile(kFileExtensions[i]), INVALID_HANDLE_VALUE); + for (const wchar_t* kExtension : kFileExtensions) + CHECK_NE(GetMarkerFile(kExtension), INVALID_HANDLE_VALUE); return SBOX_TEST_SUCCEEDED; case AFTER_REVERT: { @@ -134,8 +134,8 @@ SBOX_TESTS_COMMAND int CheckForEventHandles(int argc, wchar_t** argv) { switch (state++) { case BEFORE_INIT: // Create a unique marker file that is open while the test is running. - for (int i = 0; i < arraysize(kFileExtensions); ++i) { - HANDLE handle = GetMarkerFile(kFileExtensions[i]); + for (const wchar_t* kExtension : kFileExtensions) { + HANDLE handle = GetMarkerFile(kExtension); CHECK_NE(handle, INVALID_HANDLE_VALUE); to_check.push_back(handle); } @@ -195,9 +195,9 @@ TEST(HandleCloserTest, CheckForMarkerFiles) { runner.SetTestState(EVERY_STATE); base::string16 command = base::string16(L"CheckForFileHandles Y"); - for (int i = 0; i < arraysize(kFileExtensions); ++i) { + for (const wchar_t* kExtension : kFileExtensions) { base::string16 handle_name; - base::win::ScopedHandle marker(GetMarkerFile(kFileExtensions[i])); + base::win::ScopedHandle marker(GetMarkerFile(kExtension)); CHECK(marker.IsValid()); CHECK(sandbox::GetHandleName(marker.Get(), &handle_name)); command += (L" "); @@ -215,9 +215,9 @@ TEST(HandleCloserTest, CloseMarkerFiles) { sandbox::TargetPolicy* policy = runner.GetPolicy(); base::string16 command = base::string16(L"CheckForFileHandles N"); - for (int i = 0; i < arraysize(kFileExtensions); ++i) { + for (const wchar_t* kExtension : kFileExtensions) { base::string16 handle_name; - base::win::ScopedHandle marker(GetMarkerFile(kFileExtensions[i])); + base::win::ScopedHandle marker(GetMarkerFile(kExtension)); CHECK(marker.IsValid()); CHECK(sandbox::GetHandleName(marker.Get(), &handle_name)); CHECK_EQ(policy->AddKernelObjectToClose(L"File", handle_name.c_str()), @@ -236,9 +236,9 @@ TEST(HandleCloserTest, CheckStuffedHandle) { runner.SetTestState(EVERY_STATE); sandbox::TargetPolicy* policy = runner.GetPolicy(); - for (int i = 0; i < arraysize(kFileExtensions); ++i) { + for (const wchar_t* kExtension : kFileExtensions) { base::string16 handle_name; - base::win::ScopedHandle marker(GetMarkerFile(kFileExtensions[i])); + base::win::ScopedHandle marker(GetMarkerFile(kExtension)); CHECK(marker.IsValid()); CHECK(sandbox::GetHandleName(marker.Get(), &handle_name)); CHECK_EQ(policy->AddKernelObjectToClose(L"File", handle_name.c_str()), diff --git a/sandbox/win/src/interception_unittest.cc b/sandbox/win/src/interception_unittest.cc index 7ce5724..891c353 100644 --- a/sandbox/win/src/interception_unittest.cc +++ b/sandbox/win/src/interception_unittest.cc @@ -118,7 +118,7 @@ TEST(InterceptionManagerTest, GetGranularAlignedRandomOffset) { max_val = std::max(val, max_val); } ASSERT_EQ(max_val, kAllocGranularity - kAlignment); - ASSERT_EQ(min_val, 0); + ASSERT_EQ(0u, min_val); ASSERT_EQ(min_nonzero_val, kAlignment); } @@ -179,7 +179,7 @@ TEST(InterceptionManagerTest, BufferLayout1) { INTERCEPTION_EAT, function, OPEN_KEY_ID); // Verify that all interceptions were added - ASSERT_EQ(18, interceptions.interceptions_.size()); + ASSERT_EQ(18u, interceptions.interceptions_.size()); size_t buffer_size = interceptions.GetBufferSize(); scoped_ptr<BYTE[]> local_buffer(new BYTE[buffer_size]); @@ -195,7 +195,7 @@ TEST(InterceptionManagerTest, BufferLayout1) { // first group remains on the list of interceptions (inside the object // "interceptions"). There are 3 local interceptions (of ntdll); the // other 15 have to be sent to the child to be performed "hot". - EXPECT_EQ(3, interceptions.interceptions_.size()); + EXPECT_EQ(3u, interceptions.interceptions_.size()); int num_dlls, num_functions, num_names; WalkBuffer(local_buffer.get(), buffer_size, &num_dlls, &num_functions, @@ -232,7 +232,7 @@ TEST(InterceptionManagerTest, BufferLayout2) { INTERCEPTION_SMART_SIDESTEP, function, OPEN_FILE_ID); // Verify that all interceptions were added - ASSERT_EQ(5, interceptions.interceptions_.size()); + ASSERT_EQ(5u, interceptions.interceptions_.size()); size_t buffer_size = interceptions.GetBufferSize(); scoped_ptr<BYTE[]> local_buffer(new BYTE[buffer_size]); @@ -245,7 +245,7 @@ TEST(InterceptionManagerTest, BufferLayout2) { // group with the interceptions belonging to dlls that will be "hot" // patched on the client. The second group lives on local_buffer, and the // first group remains on the list of interceptions, in this case just one. - EXPECT_EQ(1, interceptions.interceptions_.size()); + EXPECT_EQ(1u, interceptions.interceptions_.size()); int num_dlls, num_functions, num_names; WalkBuffer(local_buffer.get(), buffer_size, &num_dlls, &num_functions, diff --git a/sandbox/win/src/ipc_unittest.cc b/sandbox/win/src/ipc_unittest.cc index e8b0b81..9b61a43 100644 --- a/sandbox/win/src/ipc_unittest.cc +++ b/sandbox/win/src/ipc_unittest.cc @@ -68,11 +68,11 @@ TEST(IPCTest, ChannelMaker) { size_t channel_start = 0; IPCControl* client_control = MakeChannels(12 * 64, 4096, &channel_start); ASSERT_TRUE(NULL != client_control); - EXPECT_EQ(5, client_control->channels_count); + EXPECT_EQ(5u, client_control->channels_count); #if defined(_WIN64) - EXPECT_EQ(216, channel_start); + EXPECT_EQ(216u, channel_start); #else - EXPECT_EQ(108, channel_start); + EXPECT_EQ(108u, channel_start); #endif delete[] reinterpret_cast<char*>(client_control); } @@ -166,7 +166,7 @@ TEST(IPCTest, CrossCallStrPacking) { CrossCall(client, tag1, text, &answer); actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); - EXPECT_EQ(1, actual_params->GetParamsCount()); + EXPECT_EQ(1u, actual_params->GetParamsCount()); EXPECT_EQ(tag1, actual_params->GetTag()); EXPECT_TRUE(actual_params->GetParameterStr(0, &copied_text)); EXPECT_STREQ(text, copied_text.c_str()); @@ -176,13 +176,13 @@ TEST(IPCTest, CrossCallStrPacking) { const wchar_t* null_text = NULL; CrossCall(client, tag2, null_text, &answer); actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); - EXPECT_EQ(1, actual_params->GetParamsCount()); + EXPECT_EQ(1u, actual_params->GetParamsCount()); EXPECT_EQ(tag2, actual_params->GetTag()); uint32_t param_size = 1; ArgType type = INVALID_TYPE; void* param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); EXPECT_TRUE(NULL != param_addr); - EXPECT_EQ(0, param_size); + EXPECT_EQ(0u, param_size); EXPECT_EQ(WCHAR_TYPE, type); EXPECT_TRUE(actual_params->GetParameterStr(0, &copied_text)); @@ -193,12 +193,12 @@ TEST(IPCTest, CrossCallStrPacking) { // Check with an empty string and a non-empty string. CrossCall(client, tag3, null_text, text, &answer); actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); - EXPECT_EQ(2, actual_params->GetParamsCount()); + EXPECT_EQ(2u, actual_params->GetParamsCount()); EXPECT_EQ(tag3, actual_params->GetTag()); type = INVALID_TYPE; param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); EXPECT_TRUE(NULL != param_addr); - EXPECT_EQ(0, param_size); + EXPECT_EQ(0u, param_size); EXPECT_EQ(WCHAR_TYPE, type); EXPECT_TRUE(actual_params->GetParameterStr(0, &copied_text)); EXPECT_TRUE(actual_params->GetParameterStr(1, &copied_text)); @@ -210,7 +210,7 @@ TEST(IPCTest, CrossCallStrPacking) { const wchar_t *text2 = L"AeFG"; CrossCall(client, tag1, text2, null_text, text, &answer); actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); - EXPECT_EQ(3, actual_params->GetParamsCount()); + EXPECT_EQ(3u, actual_params->GetParamsCount()); EXPECT_EQ(tag1, actual_params->GetTag()); EXPECT_TRUE(actual_params->GetParameterStr(0, &copied_text_p0)); EXPECT_STREQ(text2, copied_text_p0.c_str()); @@ -219,7 +219,7 @@ TEST(IPCTest, CrossCallStrPacking) { type = INVALID_TYPE; param_addr = actual_params->GetRawParameter(1, ¶m_size, &type); EXPECT_TRUE(NULL != param_addr); - EXPECT_EQ(0, param_size); + EXPECT_EQ(0u, param_size); EXPECT_EQ(WCHAR_TYPE, type); CloseChannelEvents(client_control); @@ -246,7 +246,7 @@ TEST(IPCTest, CrossCallIntPacking) { DWORD dw = 0xE6578; CrossCall(client, tag2, dw, &answer); actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); - EXPECT_EQ(1, actual_params->GetParamsCount()); + EXPECT_EQ(1u, actual_params->GetParamsCount()); EXPECT_EQ(tag2, actual_params->GetTag()); ArgType type = INVALID_TYPE; uint32_t param_size = 1; @@ -260,7 +260,7 @@ TEST(IPCTest, CrossCallIntPacking) { HANDLE h = HANDLE(0x70000500); CrossCall(client, tag1, text, h, &answer); actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); - EXPECT_EQ(2, actual_params->GetParamsCount()); + EXPECT_EQ(2u, actual_params->GetParamsCount()); EXPECT_EQ(tag1, actual_params->GetTag()); type = INVALID_TYPE; param_addr = actual_params->GetRawParameter(1, ¶m_size, &type); @@ -272,7 +272,7 @@ TEST(IPCTest, CrossCallIntPacking) { // Check combination of 32 and 64 bits. CrossCall(client, tag2, h, dw, h, &answer); actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); - EXPECT_EQ(3, actual_params->GetParamsCount()); + EXPECT_EQ(3u, actual_params->GetParamsCount()); EXPECT_EQ(tag2, actual_params->GetTag()); type = INVALID_TYPE; param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); @@ -313,7 +313,7 @@ TEST(IPCTest, CrossCallValidation) { ASSERT_TRUE(NULL != ccp); EXPECT_TRUE(ccp->GetBuffer() != buffer); EXPECT_EQ(kTag, ccp->GetTag()); - EXPECT_EQ(1, ccp->GetParamsCount()); + EXPECT_EQ(1u, ccp->GetParamsCount()); delete[] (reinterpret_cast<char*>(ccp)); // Test that we handle integer overflow on the number of params @@ -434,7 +434,7 @@ TEST(IPCTest, ClientFastServer) { EXPECT_EQ(kBusyChannel, client_control->channels[1].state); EXPECT_EQ(kFreeChannel, client_control->channels[2].state); - EXPECT_EQ(0, client_control->channels[1].ipc_tag); + EXPECT_EQ(0u, client_control->channels[1].ipc_tag); uint32_t tag = 7654; CrossCallReturn answer; diff --git a/sandbox/win/src/job_unittest.cc b/sandbox/win/src/job_unittest.cc index d176367..7ed9cf0 100644 --- a/sandbox/win/src/job_unittest.cc +++ b/sandbox/win/src/job_unittest.cc @@ -16,7 +16,8 @@ TEST(JobTest, TestCreation) { { // Create the job. Job job; - ASSERT_EQ(ERROR_SUCCESS, job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0, 0)); // check if the job exists. HANDLE job_handle = ::OpenJobObjectW(GENERIC_ALL, FALSE, @@ -30,7 +31,7 @@ TEST(JobTest, TestCreation) { // Check if the job is destroyed when the object goes out of scope. HANDLE job_handle = ::OpenJobObjectW(GENERIC_ALL, FALSE, L"my_test_job_name"); ASSERT_TRUE(job_handle == NULL); - ASSERT_EQ(ERROR_FILE_NOT_FOUND, ::GetLastError()); + ASSERT_EQ(static_cast<DWORD>(ERROR_FILE_NOT_FOUND), ::GetLastError()); } // Tests the method "Take". @@ -40,7 +41,8 @@ TEST(JobTest, Take) { { // Create the job. Job job; - ASSERT_EQ(ERROR_SUCCESS, job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0, 0)); job_handle = job.Take(); ASSERT_TRUE(job_handle.IsValid()); @@ -61,7 +63,7 @@ TEST(JobTest, Take) { // Check if the jbo is really dead. job_handle_dup = ::OpenJobObjectW(GENERIC_ALL, FALSE, L"my_test_job_name"); ASSERT_TRUE(job_handle_dup == NULL); - ASSERT_EQ(ERROR_FILE_NOT_FOUND, ::GetLastError()); + ASSERT_EQ(static_cast<DWORD>(ERROR_FILE_NOT_FOUND), ::GetLastError()); } // Tests the ui exceptions @@ -71,8 +73,9 @@ TEST(JobTest, TestExceptions) { { // Create the job. Job job; - ASSERT_EQ(ERROR_SUCCESS, job.Init(JOB_LOCKDOWN, L"my_test_job_name", - JOB_OBJECT_UILIMIT_READCLIPBOARD, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job.Init(JOB_LOCKDOWN, L"my_test_job_name", + JOB_OBJECT_UILIMIT_READCLIPBOARD, 0)); job_handle = job.Take(); ASSERT_TRUE(job_handle.IsValid()); @@ -84,7 +87,7 @@ TEST(JobTest, TestExceptions) { &jbur, size, &size); ASSERT_TRUE(result); - ASSERT_EQ(jbur.UIRestrictionsClass & JOB_OBJECT_UILIMIT_READCLIPBOARD, 0); + ASSERT_EQ(0u, jbur.UIRestrictionsClass & JOB_OBJECT_UILIMIT_READCLIPBOARD); job_handle.Close(); } @@ -92,7 +95,8 @@ TEST(JobTest, TestExceptions) { { // Create the job. Job job; - ASSERT_EQ(ERROR_SUCCESS, job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0, 0)); job_handle = job.Take(); ASSERT_TRUE(job_handle.IsValid()); @@ -104,8 +108,8 @@ TEST(JobTest, TestExceptions) { &jbur, size, &size); ASSERT_TRUE(result); - ASSERT_EQ(jbur.UIRestrictionsClass & JOB_OBJECT_UILIMIT_READCLIPBOARD, - JOB_OBJECT_UILIMIT_READCLIPBOARD); + ASSERT_EQ(static_cast<DWORD>(JOB_OBJECT_UILIMIT_READCLIPBOARD), + jbur.UIRestrictionsClass & JOB_OBJECT_UILIMIT_READCLIPBOARD); } } @@ -113,51 +117,59 @@ TEST(JobTest, TestExceptions) { TEST(JobTest, DoubleInit) { // Create the job. Job job; - ASSERT_EQ(ERROR_SUCCESS, job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0, 0)); - ASSERT_EQ(ERROR_ALREADY_INITIALIZED, job.Init(JOB_LOCKDOWN, L"test", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_ALREADY_INITIALIZED), + job.Init(JOB_LOCKDOWN, L"test", 0, 0)); } // Tests the error case when we use a method and the object is not yet // initialized. TEST(JobTest, NoInit) { Job job; - ASSERT_EQ(ERROR_NO_DATA, job.UserHandleGrantAccess(NULL)); - ASSERT_EQ(ERROR_NO_DATA, job.AssignProcessToJob(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_NO_DATA), job.UserHandleGrantAccess(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_NO_DATA), job.AssignProcessToJob(NULL)); ASSERT_FALSE(job.Take().IsValid()); } // Tests the initialization of the job with different security level. TEST(JobTest, SecurityLevel) { Job job1; - ASSERT_EQ(ERROR_SUCCESS, job1.Init(JOB_LOCKDOWN, L"job1", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job1.Init(JOB_LOCKDOWN, L"job1", 0, 0)); Job job2; - ASSERT_EQ(ERROR_SUCCESS, job2.Init(JOB_RESTRICTED, L"job2", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job2.Init(JOB_RESTRICTED, L"job2", 0, 0)); Job job3; - ASSERT_EQ(ERROR_SUCCESS, job3.Init(JOB_LIMITED_USER, L"job3", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job3.Init(JOB_LIMITED_USER, L"job3", 0, 0)); Job job4; - ASSERT_EQ(ERROR_SUCCESS, job4.Init(JOB_INTERACTIVE, L"job4", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job4.Init(JOB_INTERACTIVE, L"job4", 0, 0)); Job job5; - ASSERT_EQ(ERROR_SUCCESS, job5.Init(JOB_UNPROTECTED, L"job5", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job5.Init(JOB_UNPROTECTED, L"job5", 0, 0)); // JOB_NONE means we run without a job object so Init should fail. Job job6; - ASSERT_EQ(ERROR_BAD_ARGUMENTS, job6.Init(JOB_NONE, L"job6", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_BAD_ARGUMENTS), + job6.Init(JOB_NONE, L"job6", 0, 0)); Job job7; - ASSERT_EQ(ERROR_BAD_ARGUMENTS, job7.Init( - static_cast<JobLevel>(JOB_NONE+1), L"job7", 0, 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_BAD_ARGUMENTS), + job7.Init(static_cast<JobLevel>(JOB_NONE + 1), L"job7", 0, 0)); } // Tests the method "AssignProcessToJob". TEST(JobTest, ProcessInJob) { // Create the job. Job job; - ASSERT_EQ(ERROR_SUCCESS, job.Init(JOB_UNPROTECTED, L"job_test_process", 0, - 0)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job.Init(JOB_UNPROTECTED, L"job_test_process", 0, 0)); BOOL result = FALSE; @@ -168,7 +180,8 @@ TEST(JobTest, ProcessInJob) { &temp_process_info); ASSERT_TRUE(result); base::win::ScopedProcessInformation pi(temp_process_info); - ASSERT_EQ(ERROR_SUCCESS, job.AssignProcessToJob(pi.process_handle())); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + job.AssignProcessToJob(pi.process_handle())); // Get the job handle. base::win::ScopedHandle job_handle = job.Take(); @@ -181,8 +194,8 @@ TEST(JobTest, ProcessInJob) { &jbpidl, size, &size); EXPECT_TRUE(result); - EXPECT_EQ(1, jbpidl.NumberOfAssignedProcesses); - EXPECT_EQ(1, jbpidl.NumberOfProcessIdsInList); + EXPECT_EQ(1u, jbpidl.NumberOfAssignedProcesses); + EXPECT_EQ(1u, jbpidl.NumberOfProcessIdsInList); EXPECT_EQ(pi.process_id(), jbpidl.ProcessIdList[0]); EXPECT_TRUE(::TerminateProcess(pi.process_handle(), 0)); diff --git a/sandbox/win/src/policy_low_level_unittest.cc b/sandbox/win/src/policy_low_level_unittest.cc index 4081a58..88b9c43 100644 --- a/sandbox/win/src/policy_low_level_unittest.cc +++ b/sandbox/win/src/policy_low_level_unittest.cc @@ -392,7 +392,7 @@ TEST(PolicyEngineTest, ThreeRulesTest) { EXPECT_TRUE(pr_pipe.AddNumberMatch(IF, 2, FILE_ATTRIBUTE_NORMAL, EQUAL)); size_t opc1 = pr_pipe.GetOpcodeCount(); - EXPECT_EQ(3, opc1); + EXPECT_EQ(3u, opc1); PolicyRule pr_dump(ASK_BROKER); EXPECT_TRUE(pr_dump.AddStringMatch(IF, 0, L"\\\\/?/?\\*\\Crash Reports\\*", @@ -401,7 +401,7 @@ TEST(PolicyEngineTest, ThreeRulesTest) { EXPECT_TRUE(pr_dump.AddNumberMatch(IF, 2, FILE_ATTRIBUTE_NORMAL, EQUAL)); size_t opc2 = pr_dump.GetOpcodeCount(); - EXPECT_EQ(4, opc2); + EXPECT_EQ(4u, opc2); PolicyRule pr_winexe(SIGNAL_ALARM); EXPECT_TRUE(pr_winexe.AddStringMatch(IF, 0, L"\\\\/?/?\\C:\\Windows\\*.exe", @@ -409,7 +409,7 @@ TEST(PolicyEngineTest, ThreeRulesTest) { EXPECT_TRUE(pr_winexe.AddNumberMatch(IF, 2, FILE_ATTRIBUTE_NORMAL, EQUAL)); size_t opc3 = pr_winexe.GetOpcodeCount(); - EXPECT_EQ(3, opc3); + EXPECT_EQ(3u, opc3); PolicyRule pr_adobe(GIVE_CACHED); EXPECT_TRUE(pr_adobe.AddStringMatch(IF, 0, L"c:\\adobe\\ver?.?\\", @@ -417,14 +417,14 @@ TEST(PolicyEngineTest, ThreeRulesTest) { EXPECT_TRUE(pr_adobe.AddNumberMatch(IF, 2, FILE_ATTRIBUTE_NORMAL, EQUAL)); size_t opc4 = pr_adobe.GetOpcodeCount(); - EXPECT_EQ(4, opc4); + EXPECT_EQ(4u, opc4); PolicyRule pr_none(GIVE_FIRST); EXPECT_TRUE(pr_none.AddNumberMatch(IF, 2, FILE_ATTRIBUTE_READONLY, AND)); EXPECT_TRUE(pr_none.AddNumberMatch(IF, 2, FILE_ATTRIBUTE_SYSTEM, AND)); size_t opc5 = pr_none.GetOpcodeCount(); - EXPECT_EQ(2, opc5); + EXPECT_EQ(2u, opc5); PolicyGlobal* policy = MakePolicyMemory(); diff --git a/sandbox/win/src/policy_opcodes_unittest.cc b/sandbox/win/src/policy_opcodes_unittest.cc index c999348..954aa44 100644 --- a/sandbox/win/src/policy_opcodes_unittest.cc +++ b/sandbox/win/src/policy_opcodes_unittest.cc @@ -122,7 +122,7 @@ TEST(PolicyEngineTest, TrueFalseOpcodes) { context.position = 1; context.options = kPolUseOREval; EXPECT_EQ(EVAL_TRUE, op5->Evaluate(&ppb1, 1, &context)); - EXPECT_EQ(0, context.position); + EXPECT_EQ(0u, context.position); MatchContext context2; EXPECT_EQ(context2.options, context.options); } @@ -280,7 +280,7 @@ TEST(PolicyEngineTest, WCharOpcodes1) { kPolClearContext); ASSERT_NE(nullptr, op4); EXPECT_EQ(EVAL_TRUE, op4->Evaluate(&pp_tc1, 1, &mc1)); - EXPECT_EQ(0, mc1.position); + EXPECT_EQ(0u, mc1.position); // Test that we can properly match the last part of the string PolicyOpcode* op4b = opcode_maker.MakeOpWStringMatch(0, txt4, kSeekToEnd, @@ -288,7 +288,7 @@ TEST(PolicyEngineTest, WCharOpcodes1) { kPolClearContext); ASSERT_NE(nullptr, op4b); EXPECT_EQ(EVAL_TRUE, op4b->Evaluate(&pp_tc1, 1, &mc1)); - EXPECT_EQ(0, mc1.position); + EXPECT_EQ(0u, mc1.position); // Test matching 'jumps over' over the entire string. This is the // primitive we build '*' from. @@ -296,7 +296,7 @@ TEST(PolicyEngineTest, WCharOpcodes1) { CASE_SENSITIVE, kPolNone); ASSERT_NE(nullptr, op5); EXPECT_EQ(EVAL_TRUE, op5->Evaluate(&pp_tc1, 1, &mc1)); - EXPECT_EQ(24, mc1.position); + EXPECT_EQ(24u, mc1.position); // Test that we don't match because it is not at the end of the string PolicyOpcode* op5b = opcode_maker.MakeOpWStringMatch(0, txt5, kSeekToEnd, @@ -304,7 +304,7 @@ TEST(PolicyEngineTest, WCharOpcodes1) { kPolNone); ASSERT_NE(nullptr, op5b); EXPECT_EQ(EVAL_FALSE, op5b->Evaluate(&pp_tc1, 1, &mc1)); - EXPECT_EQ(24, mc1.position); + EXPECT_EQ(24u, mc1.position); // Test that we function if the string does not fit. In this case we // try to match 'the lazy dog' against 'he lazy dog'. @@ -319,12 +319,12 @@ TEST(PolicyEngineTest, WCharOpcodes1) { CASE_SENSITIVE, kPolNone); ASSERT_NE(nullptr, op7); EXPECT_EQ(EVAL_TRUE, op7->Evaluate(&pp_tc1, 1, &mc2)); - EXPECT_EQ(37, mc2.position); + EXPECT_EQ(37u, mc2.position); // Trying to match again should fail since we are in the last char. // This also covers a couple of boundary conditions. EXPECT_EQ(EVAL_FALSE, op7->Evaluate(&pp_tc1, 1, &mc2)); - EXPECT_EQ(37, mc2.position); + EXPECT_EQ(37u, mc2.position); } TEST(PolicyEngineTest, WCharOpcodes2) { @@ -350,7 +350,7 @@ TEST(PolicyEngineTest, WCharOpcodes2) { ASSERT_NE(nullptr, op1i); EXPECT_EQ(EVAL_FALSE, op1s->Evaluate(&pp_tc1, 1, &mc1)); EXPECT_EQ(EVAL_TRUE, op1i->Evaluate(&pp_tc1, 1, &mc1)); - EXPECT_EQ(35, mc1.position); + EXPECT_EQ(35u, mc1.position); } TEST(PolicyEngineTest, ActionOpcodes) { diff --git a/sandbox/win/src/policy_target_test.cc b/sandbox/win/src/policy_target_test.cc index bb1f0b2..6e5bf15 100644 --- a/sandbox/win/src/policy_target_test.cc +++ b/sandbox/win/src/policy_target_test.cc @@ -256,9 +256,10 @@ TEST(PolicyTargetTest, DesktopPolicy) { if (result == SBOX_ALL_OK) target.Set(temp_process_info); - EXPECT_EQ(1, ::ResumeThread(target.thread_handle())); + EXPECT_EQ(1u, ::ResumeThread(target.thread_handle())); - EXPECT_EQ(WAIT_TIMEOUT, ::WaitForSingleObject(target.process_handle(), 2000)); + EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), + ::WaitForSingleObject(target.process_handle(), 2000)); EXPECT_NE(::GetThreadDesktop(target.thread_id()), ::GetThreadDesktop(::GetCurrentThreadId())); @@ -319,9 +320,10 @@ TEST(PolicyTargetTest, WinstaPolicy) { if (result == SBOX_ALL_OK) target.Set(temp_process_info); - EXPECT_EQ(1, ::ResumeThread(target.thread_handle())); + EXPECT_EQ(1u, ::ResumeThread(target.thread_handle())); - EXPECT_EQ(WAIT_TIMEOUT, ::WaitForSingleObject(target.process_handle(), 2000)); + EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), + ::WaitForSingleObject(target.process_handle(), 2000)); EXPECT_NE(::GetThreadDesktop(target.thread_id()), ::GetThreadDesktop(::GetCurrentThreadId())); @@ -399,9 +401,9 @@ TEST(PolicyTargetTest, ShareHandleTest) { if (result == SBOX_ALL_OK) target.Set(temp_process_info); - EXPECT_EQ(1, ::ResumeThread(target.thread_handle())); + EXPECT_EQ(1u, ::ResumeThread(target.thread_handle())); - EXPECT_EQ(WAIT_TIMEOUT, + EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), ::WaitForSingleObject(target.process_handle(), 2000)); EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); diff --git a/sandbox/win/src/restricted_token_unittest.cc b/sandbox/win/src/restricted_token_unittest.cc index fca1a07..b11948e 100644 --- a/sandbox/win/src/restricted_token_unittest.cc +++ b/sandbox/win/src/restricted_token_unittest.cc @@ -19,7 +19,8 @@ namespace sandbox { // Tests the initializatioin with an invalid token handle. TEST(RestrictedTokenTest, InvalidHandle) { RestrictedToken token; - ASSERT_EQ(ERROR_INVALID_HANDLE, token.Init(reinterpret_cast<HANDLE>(0x5555))); + ASSERT_EQ(static_cast<DWORD>(ERROR_INVALID_HANDLE), + token.Init(reinterpret_cast<HANDLE>(0x5555))); } // Tests the initialization with NULL as parameter. @@ -36,13 +37,13 @@ TEST(RestrictedTokenTest, DefaultInit) { // Create the token using the current token. RestrictedToken token_default; - ASSERT_EQ(ERROR_SUCCESS, token_default.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token_default.Init(NULL)); // Get the handle to the restricted token. base::win::ScopedHandle restricted_token_handle; - ASSERT_EQ(ERROR_SUCCESS, - token_default.GetRestrictedToken(&restricted_token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token_default.GetRestrictedToken(&restricted_token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(restricted_token_handle.Take()); @@ -78,13 +79,14 @@ TEST(RestrictedTokenTest, CustomInit) { // Create the token using the current token. RestrictedToken token; - ASSERT_EQ(ERROR_SUCCESS, token.Init(access_token.GetHandle())); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.Init(access_token.GetHandle())); // Get the handle to the restricted token. base::win::ScopedHandle restricted_token_handle; - ASSERT_EQ(ERROR_SUCCESS, - token.GetRestrictedToken(&restricted_token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&restricted_token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(restricted_token_handle.Take()); @@ -101,13 +103,14 @@ TEST(RestrictedTokenTest, CustomInit) { // Verifies that the token created by the object are valid. TEST(RestrictedTokenTest, ResultToken) { RestrictedToken token; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.AddRestrictingSid(ATL::Sids::World().GetPSID())); base::win::ScopedHandle restricted_token; - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&restricted_token)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&restricted_token)); ASSERT_TRUE(::IsTokenRestricted(restricted_token.Get())); @@ -122,8 +125,8 @@ TEST(RestrictedTokenTest, ResultToken) { ASSERT_EQ(type, TokenPrimary); base::win::ScopedHandle impersonation_token; - ASSERT_EQ(ERROR_SUCCESS, - token.GetRestrictedTokenForImpersonation(&impersonation_token)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedTokenForImpersonation(&impersonation_token)); ASSERT_TRUE(::IsTokenRestricted(impersonation_token.Get())); @@ -139,13 +142,14 @@ TEST(RestrictedTokenTest, ResultToken) { // Verifies that the token created has "Restricted" in its default dacl. TEST(RestrictedTokenTest, DefaultDacl) { RestrictedToken token; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.AddRestrictingSid(ATL::Sids::World().GetPSID())); base::win::ScopedHandle handle; - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(handle.Take()); @@ -174,9 +178,11 @@ TEST(RestrictedTokenTest, DenySid) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.AddSidForDenyOnly(Sid(WinWorldSid))); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddSidForDenyOnly(Sid(WinWorldSid))); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -190,7 +196,7 @@ TEST(RestrictedTokenTest, DenySid) { for (unsigned int i = 0; i < sids.GetCount(); i++) { if (ATL::Sids::World() == sids[i]) { - ASSERT_EQ(SE_GROUP_USE_FOR_DENY_ONLY, + ASSERT_EQ(static_cast<DWORD>(SE_GROUP_USE_FOR_DENY_ONLY), attributes[i] & SE_GROUP_USE_FOR_DENY_ONLY); } } @@ -201,9 +207,11 @@ TEST(RestrictedTokenTest, DenySids) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.AddAllSidsForDenyOnly(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddAllSidsForDenyOnly(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -219,7 +227,7 @@ TEST(RestrictedTokenTest, DenySids) { for (unsigned int i = 0; i < sids.GetCount(); i++) { if ((attributes[i] & SE_GROUP_LOGON_ID) == 0 && (attributes[i] & SE_GROUP_INTEGRITY) == 0) { - ASSERT_EQ(SE_GROUP_USE_FOR_DENY_ONLY, + ASSERT_EQ(static_cast<DWORD>(SE_GROUP_USE_FOR_DENY_ONLY), attributes[i] & SE_GROUP_USE_FOR_DENY_ONLY); } } @@ -233,9 +241,11 @@ TEST(RestrictedTokenTest, DenySidsException) { std::vector<Sid> sids_exception; sids_exception.push_back(Sid(WinWorldSid)); - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.AddAllSidsForDenyOnly(&sids_exception)); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddAllSidsForDenyOnly(&sids_exception)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -252,9 +262,9 @@ TEST(RestrictedTokenTest, DenySidsException) { if ((attributes[i] & SE_GROUP_LOGON_ID) == 0 && (attributes[i] & SE_GROUP_INTEGRITY) == 0) { if (ATL::Sids::World() == sids[i]) { - ASSERT_EQ(NULL, attributes[i] & SE_GROUP_USE_FOR_DENY_ONLY); + ASSERT_EQ(0u, attributes[i] & SE_GROUP_USE_FOR_DENY_ONLY); } else { - ASSERT_EQ(SE_GROUP_USE_FOR_DENY_ONLY, + ASSERT_EQ(static_cast<DWORD>(SE_GROUP_USE_FOR_DENY_ONLY), attributes[i] & SE_GROUP_USE_FOR_DENY_ONLY); } } @@ -266,9 +276,10 @@ TEST(RestrictedTokenTest, DenyOwnerSid) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.AddUserSidForDenyOnly()); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.AddUserSidForDenyOnly()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -285,7 +296,7 @@ TEST(RestrictedTokenTest, DenyOwnerSid) { for (unsigned int i = 0; i < sids.GetCount(); ++i) { if (user_sid == sids[i]) { - ASSERT_EQ(SE_GROUP_USE_FOR_DENY_ONLY, + ASSERT_EQ(static_cast<DWORD>(SE_GROUP_USE_FOR_DENY_ONLY), attributes[i] & SE_GROUP_USE_FOR_DENY_ONLY); } } @@ -305,9 +316,11 @@ TEST(RestrictedTokenTest, DenyOwnerSidCustom) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(access_token.GetHandle())); - ASSERT_EQ(ERROR_SUCCESS, token.AddUserSidForDenyOnly()); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.Init(access_token.GetHandle())); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.AddUserSidForDenyOnly()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -324,7 +337,7 @@ TEST(RestrictedTokenTest, DenyOwnerSidCustom) { for (unsigned int i = 0; i < sids.GetCount(); ++i) { if (user_sid == sids[i]) { - ASSERT_EQ(SE_GROUP_USE_FOR_DENY_ONLY, + ASSERT_EQ(static_cast<DWORD>(SE_GROUP_USE_FOR_DENY_ONLY), attributes[i] & SE_GROUP_USE_FOR_DENY_ONLY); } } @@ -335,9 +348,10 @@ TEST(RestrictedTokenTest, DeleteAllPrivileges) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.DeleteAllPrivileges(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.DeleteAllPrivileges(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -345,7 +359,7 @@ TEST(RestrictedTokenTest, DeleteAllPrivileges) { ATL::CTokenPrivileges privileges; ASSERT_TRUE(restricted_token.GetPrivileges(&privileges)); - ASSERT_EQ(0, privileges.GetCount()); + ASSERT_EQ(0u, privileges.GetCount()); } // Tests the method DeleteAllPrivileges with an exception list. @@ -356,9 +370,11 @@ TEST(RestrictedTokenTest, DeleteAllPrivilegesException) { std::vector<base::string16> exceptions; exceptions.push_back(SE_CHANGE_NOTIFY_NAME); - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.DeleteAllPrivileges(&exceptions)); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.DeleteAllPrivileges(&exceptions)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -371,7 +387,7 @@ TEST(RestrictedTokenTest, DeleteAllPrivilegesException) { privileges.GetNamesAndAttributes(&privilege_names, &privilege_name_attributes); - ASSERT_EQ(1, privileges.GetCount()); + ASSERT_EQ(1u, privileges.GetCount()); for (unsigned int i = 0; i < privileges.GetCount(); ++i) { ASSERT_EQ(privilege_names[i], SE_CHANGE_NOTIFY_NAME); @@ -383,9 +399,11 @@ TEST(RestrictedTokenTest, DeletePrivilege) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.DeletePrivilege(SE_CHANGE_NOTIFY_NAME)); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.DeletePrivilege(SE_CHANGE_NOTIFY_NAME)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -421,7 +439,7 @@ void CheckRestrictingSid(const ATL::CAccessToken &restricted_token, delete[] memory; if (count >= 0) - ASSERT_EQ(count, atl_groups.GetCount()); + ASSERT_EQ(static_cast<unsigned>(count), atl_groups.GetCount()); ATL::CSid::CSidArray sids; ATL::CAtlArray<DWORD> attributes; @@ -443,10 +461,11 @@ TEST(RestrictedTokenTest, AddRestrictingSid) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.AddRestrictingSid(ATL::Sids::World().GetPSID())); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -459,9 +478,11 @@ TEST(RestrictedTokenTest, AddRestrictingSidCurrentUser) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.AddRestrictingSidCurrentUser()); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddRestrictingSidCurrentUser()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -485,9 +506,12 @@ TEST(RestrictedTokenTest, AddRestrictingSidCurrentUserCustom) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(access_token.GetHandle())); - ASSERT_EQ(ERROR_SUCCESS, token.AddRestrictingSidCurrentUser()); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.Init(access_token.GetHandle())); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddRestrictingSidCurrentUser()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -502,9 +526,11 @@ TEST(RestrictedTokenTest, AddRestrictingSidLogonSession) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.AddRestrictingSidLogonSession()); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddRestrictingSidLogonSession()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -519,12 +545,15 @@ TEST(RestrictedTokenTest, AddMultipleRestrictingSids) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.AddRestrictingSidCurrentUser()); - ASSERT_EQ(ERROR_SUCCESS, token.AddRestrictingSidLogonSession()); - ASSERT_EQ(ERROR_SUCCESS, + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddRestrictingSidCurrentUser()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddRestrictingSidLogonSession()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.AddRestrictingSid(ATL::Sids::World().GetPSID())); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -543,7 +572,7 @@ TEST(RestrictedTokenTest, AddMultipleRestrictingSids) { ATL::CTokenGroups atl_groups(*groups); delete[] memory; - ASSERT_EQ(3, atl_groups.GetCount()); + ASSERT_EQ(3u, atl_groups.GetCount()); } // Tests the method "AddRestrictingSidAllSids". @@ -551,9 +580,11 @@ TEST(RestrictedTokenTest, AddAllSidToRestrictingSids) { RestrictedToken token; base::win::ScopedHandle token_handle; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); - ASSERT_EQ(ERROR_SUCCESS, token.AddRestrictingSidAllSids()); - ASSERT_EQ(ERROR_SUCCESS, token.GetRestrictedToken(&token_handle)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.AddRestrictingSidAllSids()); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.GetRestrictedToken(&token_handle)); ATL::CAccessToken restricted_token; restricted_token.Attach(token_handle.Take()); @@ -581,9 +612,9 @@ TEST(RestrictedTokenTest, AddAllSidToRestrictingSids) { // Checks the error code when the object is initialized twice. TEST(RestrictedTokenTest, DoubleInit) { RestrictedToken token; - ASSERT_EQ(ERROR_SUCCESS, token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); - ASSERT_EQ(ERROR_ALREADY_INITIALIZED, token.Init(NULL)); + ASSERT_EQ(static_cast<DWORD>(ERROR_ALREADY_INITIALIZED), token.Init(NULL)); } } // namespace sandbox diff --git a/sandbox/win/src/sandbox_policy_base.cc b/sandbox/win/src/sandbox_policy_base.cc index 17f52c5..2b82f10 100644 --- a/sandbox/win/src/sandbox_policy_base.cc +++ b/sandbox/win/src/sandbox_policy_base.cc @@ -635,7 +635,7 @@ const AppContainerAttributes* PolicyBase::GetAppContainer() const { return appcontainer_list_.get(); } -const PSID PolicyBase::GetLowBoxSid() const { +PSID PolicyBase::GetLowBoxSid() const { return lowbox_sid_; } diff --git a/sandbox/win/src/sandbox_policy_base.h b/sandbox/win/src/sandbox_policy_base.h index a461bd7..0068553 100644 --- a/sandbox/win/src/sandbox_policy_base.h +++ b/sandbox/win/src/sandbox_policy_base.h @@ -90,7 +90,7 @@ class PolicyBase : public Dispatcher, public TargetPolicy { const AppContainerAttributes* GetAppContainer() const; - const PSID GetLowBoxSid() const; + PSID GetLowBoxSid() const; // Adds a target process to the internal list of targets. Internally a // call to TargetProcess::Init() is issued. diff --git a/sandbox/win/src/threadpool_unittest.cc b/sandbox/win/src/threadpool_unittest.cc index f439810..4f3b0df 100644 --- a/sandbox/win/src/threadpool_unittest.cc +++ b/sandbox/win/src/threadpool_unittest.cc @@ -19,22 +19,22 @@ namespace sandbox { TEST(IPCTest, ThreadPoolRegisterTest1) { Win2kThreadPool thread_pool; - EXPECT_EQ(0, thread_pool.OutstandingWaits()); + EXPECT_EQ(0u, thread_pool.OutstandingWaits()); HANDLE event1 = ::CreateEventW(NULL, FALSE, FALSE, NULL); HANDLE event2 = ::CreateEventW(NULL, FALSE, FALSE, NULL); uint32 context = 0; EXPECT_FALSE(thread_pool.RegisterWait(0, event1, EmptyCallBack, &context)); - EXPECT_EQ(0, thread_pool.OutstandingWaits()); + EXPECT_EQ(0u, thread_pool.OutstandingWaits()); EXPECT_TRUE(thread_pool.RegisterWait(this, event1, EmptyCallBack, &context)); - EXPECT_EQ(1, thread_pool.OutstandingWaits()); + EXPECT_EQ(1u, thread_pool.OutstandingWaits()); EXPECT_TRUE(thread_pool.RegisterWait(this, event2, EmptyCallBack, &context)); - EXPECT_EQ(2, thread_pool.OutstandingWaits()); + EXPECT_EQ(2u, thread_pool.OutstandingWaits()); EXPECT_TRUE(thread_pool.UnRegisterWaits(this)); - EXPECT_EQ(0, thread_pool.OutstandingWaits()); + EXPECT_EQ(0u, thread_pool.OutstandingWaits()); EXPECT_EQ(TRUE, ::CloseHandle(event1)); EXPECT_EQ(TRUE, ::CloseHandle(event2)); @@ -52,17 +52,17 @@ TEST(IPCTest, ThreadPoolRegisterTest2) { uint32 c2 = 0; EXPECT_TRUE(thread_pool.RegisterWait(&c1, event1, EmptyCallBack, &context)); - EXPECT_EQ(1, thread_pool.OutstandingWaits()); + EXPECT_EQ(1u, thread_pool.OutstandingWaits()); EXPECT_TRUE(thread_pool.RegisterWait(&c2, event2, EmptyCallBack, &context)); - EXPECT_EQ(2, thread_pool.OutstandingWaits()); + EXPECT_EQ(2u, thread_pool.OutstandingWaits()); EXPECT_TRUE(thread_pool.UnRegisterWaits(&c2)); - EXPECT_EQ(1, thread_pool.OutstandingWaits()); + EXPECT_EQ(1u, thread_pool.OutstandingWaits()); EXPECT_TRUE(thread_pool.UnRegisterWaits(&c2)); - EXPECT_EQ(1, thread_pool.OutstandingWaits()); + EXPECT_EQ(1u, thread_pool.OutstandingWaits()); EXPECT_TRUE(thread_pool.UnRegisterWaits(&c1)); - EXPECT_EQ(0, thread_pool.OutstandingWaits()); + EXPECT_EQ(0u, thread_pool.OutstandingWaits()); EXPECT_EQ(TRUE, ::CloseHandle(event1)); EXPECT_EQ(TRUE, ::CloseHandle(event2)); @@ -83,9 +83,10 @@ TEST(IPCTest, ThreadPoolSignalAndWaitTest) { EXPECT_EQ(WAIT_OBJECT_0, ::SignalObjectAndWait(event1, event2, 5000, FALSE)); EXPECT_TRUE(thread_pool.UnRegisterWaits(this)); - EXPECT_EQ(0, thread_pool.OutstandingWaits()); + EXPECT_EQ(0u, thread_pool.OutstandingWaits()); - EXPECT_EQ(WAIT_TIMEOUT, ::SignalObjectAndWait(event1, event2, 1000, FALSE)); + EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), + ::SignalObjectAndWait(event1, event2, 1000, FALSE)); EXPECT_EQ(TRUE, ::CloseHandle(event1)); EXPECT_EQ(TRUE, ::CloseHandle(event2)); diff --git a/sandbox/win/src/win_utils_unittest.cc b/sandbox/win/src/win_utils_unittest.cc index 15da51b..fb72eb33 100644 --- a/sandbox/win/src/win_utils_unittest.cc +++ b/sandbox/win/src/win_utils_unittest.cc @@ -22,13 +22,16 @@ TEST(WinUtils, IsReparsePoint) { ASSERT_TRUE(::DeleteFile(my_folder)); ASSERT_TRUE(::CreateDirectory(my_folder, NULL)); - EXPECT_EQ(ERROR_NOT_A_REPARSE_POINT, IsReparsePoint(my_folder)); + EXPECT_EQ(static_cast<DWORD>(ERROR_NOT_A_REPARSE_POINT), + IsReparsePoint(my_folder)); base::string16 not_found = base::string16(my_folder) + L"\\foo\\bar"; - EXPECT_EQ(ERROR_NOT_A_REPARSE_POINT, IsReparsePoint(not_found)); + EXPECT_EQ(static_cast<DWORD>(ERROR_NOT_A_REPARSE_POINT), + IsReparsePoint(not_found)); base::string16 new_file = base::string16(my_folder) + L"\\foo"; - EXPECT_EQ(ERROR_NOT_A_REPARSE_POINT, IsReparsePoint(new_file)); + EXPECT_EQ(static_cast<DWORD>(ERROR_NOT_A_REPARSE_POINT), + IsReparsePoint(new_file)); // Replace the directory with a reparse point to %temp%. HANDLE dir = ::CreateFile(my_folder, FILE_ALL_ACCESS, @@ -39,7 +42,7 @@ TEST(WinUtils, IsReparsePoint) { base::string16 temp_dir_nt = base::string16(L"\\??\\") + temp_directory; EXPECT_TRUE(SetReparsePoint(dir, temp_dir_nt.c_str())); - EXPECT_EQ(ERROR_SUCCESS, IsReparsePoint(new_file)); + EXPECT_EQ(static_cast<DWORD>(ERROR_SUCCESS), IsReparsePoint(new_file)); EXPECT_TRUE(DeleteReparsePoint(dir)); EXPECT_TRUE(::CloseHandle(dir)); diff --git a/ui/base/ime/remote_input_method_win.cc b/ui/base/ime/remote_input_method_win.cc index e9f7fc2..2fbb8ac 100644 --- a/ui/base/ime/remote_input_method_win.cc +++ b/ui/base/ime/remote_input_method_win.cc @@ -60,7 +60,7 @@ std::string GetLocaleString(LCID Locale_id, LCTYPE locale_type) { //|chars_written| includes NUL terminator. const int chars_written = GetLocaleInfo(Locale_id, locale_type, buffer, arraysize(buffer)); - if (chars_written <= 1 || arraysize(buffer) < chars_written) + if (chars_written <= 1 || static_cast<int>(arraysize(buffer)) < chars_written) return std::string(); std::string result; base::WideToUTF8(buffer, chars_written - 1, &result); diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc index cf05c89..9183476 100644 --- a/ui/native_theme/native_theme_win.cc +++ b/ui/native_theme/native_theme_win.cc @@ -356,10 +356,8 @@ void NativeThemeWin::OnSysColorChange() { } void NativeThemeWin::UpdateSystemColors() { - for (int i = 0; i < arraysize(kSystemColors); ++i) { - system_colors_[kSystemColors[i]] = - color_utils::GetSysSkColor(kSystemColors[i]); - } + for (int kSystemColor : kSystemColors) + system_colors_[kSystemColor] = color_utils::GetSysSkColor(kSystemColor); } void NativeThemeWin::PaintDirect(SkCanvas* canvas, diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index a5dfc22..9ebb62d 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -1413,7 +1413,7 @@ LRESULT HWNDMessageHandler::OnGetObject(UINT message, DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(l_param)); // Accessibility readers will send an OBJID_CLIENT message - if (OBJID_CLIENT == obj_id) { + if (static_cast<DWORD>(OBJID_CLIENT) == obj_id) { // Retrieve MSAA dispatch object for the root view. base::win::ScopedComPtr<IAccessible> root( delegate_->GetNativeViewAccessible()); diff --git a/win8/delegate_execute/delegate_execute_util_unittest.cc b/win8/delegate_execute/delegate_execute_util_unittest.cc index 63a5075..47916fd 100644 --- a/win8/delegate_execute/delegate_execute_util_unittest.cc +++ b/win8/delegate_execute/delegate_execute_util_unittest.cc @@ -47,16 +47,16 @@ TEST(DelegateExecuteUtil, MakeChromeCommandLineTest) { this_exe, delegate_execute::CommandLineFromParameters(NULL), base::string16()); - EXPECT_EQ(1, cl.argv().size()); + EXPECT_EQ(1u, cl.argv().size()); EXPECT_EQ(this_exe.value(), cl.GetProgram().value()); // Empty params with arg contains the arg. cl = delegate_execute::MakeChromeCommandLine( this_exe, delegate_execute::CommandLineFromParameters(NULL), base::string16(kSomeArgument)); - EXPECT_EQ(2, cl.argv().size()); + EXPECT_EQ(2u, cl.argv().size()); EXPECT_EQ(this_exe.value(), cl.GetProgram().value()); - EXPECT_EQ(1, cl.GetArgs().size()); + EXPECT_EQ(1u, cl.GetArgs().size()); EXPECT_EQ(base::string16(kSomeArgument), cl.GetArgs()[0]); // Params with switchs and args plus arg contains the arg. @@ -66,11 +66,11 @@ TEST(DelegateExecuteUtil, MakeChromeCommandLineTest) { base::ASCIIToUTF16(kSomeSwitch).c_str(), kOtherArgument).c_str()), base::string16(kSomeArgument)); - EXPECT_EQ(5, cl.argv().size()); + EXPECT_EQ(5u, cl.argv().size()); EXPECT_EQ(this_exe.value(), cl.GetProgram().value()); EXPECT_TRUE(cl.HasSwitch(kSomeSwitch)); base::CommandLine::StringVector args(cl.GetArgs()); - EXPECT_EQ(2, args.size()); + EXPECT_EQ(2u, args.size()); EXPECT_NE( args.end(), std::find(args.begin(), args.end(), base::string16(kOtherArgument))); |