diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-15 09:51:36 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-15 09:51:36 +0000 |
commit | 23a918b67bf717623835bbe400dd1b75848bee8b (patch) | |
tree | 775fb4faad2d6655651cea197b8f00c85f1db633 | |
parent | c51f4d0daa2fd6a00b7a3fbe0ced67d76ad748ad (diff) | |
download | chromium_src-23a918b67bf717623835bbe400dd1b75848bee8b.zip chromium_src-23a918b67bf717623835bbe400dd1b75848bee8b.tar.gz chromium_src-23a918b67bf717623835bbe400dd1b75848bee8b.tar.bz2 |
Fixes for re-enabling more MSVC level 4 warnings: content/browser/ edition
This contains fixes for the following sorts of issues:
* Signedness mismatch
* Assignment inside conditional
* Possibly-uninitialized local variable
This also contains a very small number of other cleanups to nearby code.
BUG=81439
TEST=none
Review URL: https://codereview.chromium.org/373873002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283169 0039d316-1c4b-4281-b951-d872f2087c98
11 files changed, 36 insertions, 32 deletions
diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index 7f23dd9..add8e64 100644 --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc @@ -716,7 +716,7 @@ TEST(BrowserAccessibilityManagerWinTest, TestAccessibleHWND) { HWND desktop_hwnd = GetDesktopWindow(); base::win::ScopedComPtr<IAccessible> desktop_hwnd_iaccessible; ASSERT_EQ(S_OK, AccessibleObjectFromWindow( - desktop_hwnd, OBJID_CLIENT, + desktop_hwnd, static_cast<DWORD>(OBJID_CLIENT), IID_IAccessible, reinterpret_cast<void**>(desktop_hwnd_iaccessible.Receive()))); diff --git a/content/browser/appcache/appcache.cc b/content/browser/appcache/appcache.cc index 7b23f64..743b694 100644 --- a/content/browser/appcache/appcache.cc +++ b/content/browser/appcache/appcache.cc @@ -265,7 +265,8 @@ bool AppCache::FindResponseForRequest(const GURL& url, return true; } - if ((*found_network_namespace = IsInNetworkNamespace(url_no_ref))) + *found_network_namespace = IsInNetworkNamespace(url_no_ref); + if (*found_network_namespace) return true; const AppCacheNamespace* intercept_namespace = diff --git a/content/browser/appcache/view_appcache_internals_job.cc b/content/browser/appcache/view_appcache_internals_job.cc index 3f8ac4f..481243d 100644 --- a/content/browser/appcache/view_appcache_internals_job.cc +++ b/content/browser/appcache/view_appcache_internals_job.cc @@ -652,8 +652,8 @@ net::URLRequestJob* ViewAppCacheInternalsJobFactory::CreateJobForRequest( DecodeBase64URL(param)); std::vector<std::string> tokens; - int64 response_id; - int64 group_id; + int64 response_id = 0; + int64 group_id = 0; if (command == kViewEntryCommand && Tokenize(param, "|", &tokens) == 4u && base::StringToInt64(tokens[2], &response_id) && base::StringToInt64(tokens[3], &group_id)) { diff --git a/content/browser/devtools/renderer_overrides_handler.cc b/content/browser/devtools/renderer_overrides_handler.cc index 45964f3..9f44dd5 100644 --- a/content/browser/devtools/renderer_overrides_handler.cc +++ b/content/browser/devtools/renderer_overrides_handler.cc @@ -326,7 +326,7 @@ RendererOverridesHandler::PageHandleJavaScriptDialog( base::DictionaryValue* params = command->params(); const char* paramAccept = devtools::Page::handleJavaScriptDialog::kParamAccept; - bool accept; + bool accept = false; if (!params || !params->GetBoolean(paramAccept, &accept)) return command->InvalidParamResponse(paramAccept); base::string16 prompt_override; @@ -433,10 +433,9 @@ RendererOverridesHandler::PageGetNavigationHistory( scoped_refptr<DevToolsProtocol::Response> RendererOverridesHandler::PageNavigateToHistoryEntry( scoped_refptr<DevToolsProtocol::Command> command) { - int entry_id; - base::DictionaryValue* params = command->params(); const char* param = devtools::Page::navigateToHistoryEntry::kParamEntryId; + int entry_id = 0; if (!params || !params->GetInteger(param, &entry_id)) { return command->InvalidParamResponse(param); } @@ -980,8 +979,8 @@ RendererOverridesHandler::InputDispatchGestureEvent( event.globalY = event.y; if (type == "scrollUpdate") { - int dx; - int dy; + int dx = 0; + int dy = 0; if (!params->GetInteger( devtools::Input::dispatchGestureEvent::kParamDeltaX, &dx) || !params->GetInteger( diff --git a/content/browser/fileapi/blob_url_request_job_unittest.cc b/content/browser/fileapi/blob_url_request_job_unittest.cc index 5ce4312..4a30e11 100644 --- a/content/browser/fileapi/blob_url_request_job_unittest.cc +++ b/content/browser/fileapi/blob_url_request_job_unittest.cc @@ -260,7 +260,7 @@ TEST_F(BlobURLRequestJobTest, TestGetSimpleDataRequest) { } TEST_F(BlobURLRequestJobTest, TestGetSimpleFileRequest) { - blob_data_->AppendFile(temp_file1_, 0, -1, base::Time()); + blob_data_->AppendFile(temp_file1_, 0, kuint64max, base::Time()); TestSuccessNonrangeRequest(kTestFileData1, arraysize(kTestFileData1) - 1); } @@ -274,14 +274,14 @@ TEST_F(BlobURLRequestJobTest, TestGetLargeFileRequest) { ASSERT_EQ(static_cast<int>(large_data.size()), base::WriteFile(large_temp_file, large_data.data(), large_data.size())); - blob_data_->AppendFile(large_temp_file, 0, -1, base::Time()); + blob_data_->AppendFile(large_temp_file, 0, kuint64max, base::Time()); TestSuccessNonrangeRequest(large_data, large_data.size()); } TEST_F(BlobURLRequestJobTest, TestGetNonExistentFileRequest) { base::FilePath non_existent_file = temp_file1_.InsertBeforeExtension(FILE_PATH_LITERAL("-na")); - blob_data_->AppendFile(non_existent_file, 0, -1, base::Time()); + blob_data_->AppendFile(non_existent_file, 0, kuint64max, base::Time()); TestErrorRequest(404); } @@ -300,7 +300,7 @@ TEST_F(BlobURLRequestJobTest, TestGetSlicedFileRequest) { TEST_F(BlobURLRequestJobTest, TestGetSimpleFileSystemFileRequest) { SetUpFileSystem(); - blob_data_->AppendFileSystemFile(temp_file_system_file1_, 0, -1, + blob_data_->AppendFileSystemFile(temp_file_system_file1_, 0, kuint64max, base::Time()); TestSuccessNonrangeRequest(kTestFileSystemFileData1, arraysize(kTestFileSystemFileData1) - 1); @@ -316,7 +316,7 @@ TEST_F(BlobURLRequestJobTest, TestGetLargeFileSystemFileRequest) { const char kFilename[] = "LargeBlob.dat"; WriteFileSystemFile(kFilename, large_data.data(), large_data.size(), NULL); - blob_data_->AppendFileSystemFile(GetFileSystemURL(kFilename), 0, -1, + blob_data_->AppendFileSystemFile(GetFileSystemURL(kFilename), 0, kuint64max, base::Time()); TestSuccessNonrangeRequest(large_data, large_data.size()); } @@ -324,7 +324,8 @@ TEST_F(BlobURLRequestJobTest, TestGetLargeFileSystemFileRequest) { TEST_F(BlobURLRequestJobTest, TestGetNonExistentFileSystemFileRequest) { SetUpFileSystem(); GURL non_existent_file = GetFileSystemURL("non-existent.dat"); - blob_data_->AppendFileSystemFile(non_existent_file, 0, -1, base::Time()); + blob_data_->AppendFileSystemFile(non_existent_file, 0, kuint64max, + base::Time()); TestErrorRequest(404); } diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc index d698686..a25aeba 100644 --- a/content/browser/frame_host/navigation_controller_impl.cc +++ b/content/browser/frame_host/navigation_controller_impl.cc @@ -46,7 +46,7 @@ namespace content { namespace { -const int kInvalidateAll = 0xFFFFFFFF; +const unsigned kInvalidateAll = 0xFFFFFFFF; // Invoked when entries have been pruned, or removed. For example, if the // current entries are [google, digg, yahoo], with the current entry google, @@ -147,7 +147,7 @@ bool ShouldKeepOverride(const NavigationEntry* last_entry) { // NavigationControllerImpl ---------------------------------------------------- -const size_t kMaxEntryCountForTestingNotSet = -1; +const size_t kMaxEntryCountForTestingNotSet = static_cast<size_t>(-1); // static size_t NavigationControllerImpl::max_entry_count_for_testing_ = diff --git a/content/browser/geolocation/network_location_request.cc b/content/browser/geolocation/network_location_request.cc index 8fb6e6a..75c7c84 100644 --- a/content/browser/geolocation/network_location_request.cc +++ b/content/browser/geolocation/network_location_request.cc @@ -409,7 +409,8 @@ bool ParseServerResponse(const std::string& response_body, static_cast<const base::DictionaryValue*>(location_value); // latitude and longitude fields are always required. - double latitude, longitude; + double latitude = 0; + double longitude = 0; if (!GetAsDouble(*location_object, kLatitudeString, &latitude) || !GetAsDouble(*location_object, kLongitudeString, &longitude)) { VLOG(1) << "ParseServerResponse() : location lacks lat and/or long."; diff --git a/content/browser/indexed_db/indexed_db_leveldb_coding.cc b/content/browser/indexed_db/indexed_db_leveldb_coding.cc index d006426..a493d52 100644 --- a/content/browser/indexed_db/indexed_db_leveldb_coding.cc +++ b/content/browser/indexed_db/indexed_db_leveldb_coding.cc @@ -1436,7 +1436,7 @@ std::string DatabaseMetaDataKey::Encode(int64 database_id, } ObjectStoreMetaDataKey::ObjectStoreMetaDataKey() - : object_store_id_(-1), meta_data_type_(-1) {} + : object_store_id_(-1), meta_data_type_(0xFF) {} bool ObjectStoreMetaDataKey::Decode(StringPiece* slice, ObjectStoreMetaDataKey* result) { diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc index b79e797..1e6ad3d 100644 --- a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc +++ b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc @@ -430,7 +430,7 @@ class SyntheticGestureControllerTest : public testing::Test { TEST_F(SyntheticGestureControllerTest, SingleGesture) { CreateControllerAndTarget<MockSyntheticGestureTarget>(); - bool finished; + bool finished = false; scoped_ptr<MockSyntheticGesture> gesture( new MockSyntheticGesture(&finished, 3)); QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); @@ -444,7 +444,7 @@ TEST_F(SyntheticGestureControllerTest, SingleGesture) { TEST_F(SyntheticGestureControllerTest, GestureFailed) { CreateControllerAndTarget<MockSyntheticGestureTarget>(); - bool finished; + bool finished = false; scoped_ptr<MockSyntheticGesture> gesture( new MockSyntheticGesture(&finished, 0)); QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); @@ -458,9 +458,10 @@ TEST_F(SyntheticGestureControllerTest, GestureFailed) { TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) { CreateControllerAndTarget<MockSyntheticGestureTarget>(); - bool finished_1, finished_2; + bool finished_1 = false; scoped_ptr<MockSyntheticGesture> gesture_1( new MockSyntheticGesture(&finished_1, 2)); + bool finished_2 = false; scoped_ptr<MockSyntheticGesture> gesture_2( new MockSyntheticGesture(&finished_2, 4)); @@ -484,9 +485,10 @@ TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) { TEST_F(SyntheticGestureControllerTest, TwoGesturesInFlight) { CreateControllerAndTarget<MockSyntheticGestureTarget>(); - bool finished_1, finished_2; + bool finished_1 = false; scoped_ptr<MockSyntheticGesture> gesture_1( new MockSyntheticGesture(&finished_1, 2)); + bool finished_2 = false; scoped_ptr<MockSyntheticGesture> gesture_2( new MockSyntheticGesture(&finished_2, 4)); diff --git a/content/browser/renderer_host/p2p/socket_host.cc b/content/browser/renderer_host/p2p/socket_host.cc index 007ab77..5fc3818 100644 --- a/content/browser/renderer_host/p2p/socket_host.cc +++ b/content/browser/renderer_host/p2p/socket_host.cc @@ -221,7 +221,8 @@ bool GetRtpPacketStartPositionAndLength(const char* packet, int length, int* rtp_start_pos, int* rtp_packet_length) { - int rtp_begin, rtp_length; + int rtp_begin; + int rtp_length = 0; if (IsTurnChannelData(packet)) { // Turn Channel Message header format. // 0 1 2 3 @@ -314,7 +315,7 @@ bool GetRtpPacketStartPositionAndLength(const char* packet, } // Making sure we have a valid RTP packet at the end. - if (!(rtp_length < kMinRtpHdrLen) && + if ((rtp_length >= kMinRtpHdrLen) && IsRtpPacket(packet + rtp_begin, rtp_length) && ValidateRtpHeader(packet + rtp_begin, rtp_length, NULL)) { *rtp_start_pos = rtp_begin; diff --git a/content/browser/service_worker/service_worker_internals_ui.cc b/content/browser/service_worker/service_worker_internals_ui.cc index 5bac0ca..1421fe4 100644 --- a/content/browser/service_worker/service_worker_internals_ui.cc +++ b/content/browser/service_worker/service_worker_internals_ui.cc @@ -563,11 +563,11 @@ void ServiceWorkerInternalsUI::CallServiceWorkerVersionMethod( const ListValue* args) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); int callback_id; - int partition_id; - int64 version_id; - std::string version_id_string; const DictionaryValue* cmd_args = NULL; + int partition_id; scoped_refptr<ServiceWorkerContextWrapper> context; + std::string version_id_string; + int64 version_id = 0; if (!args->GetInteger(0, &callback_id) || !args->GetDictionary(1, &cmd_args) || !cmd_args->GetInteger("partition_id", &partition_id) || @@ -588,7 +588,7 @@ void ServiceWorkerInternalsUI::DispatchPushEvent( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); int callback_id; int partition_id; - int64 version_id; + int64 version_id = 0; std::string version_id_string; const DictionaryValue* cmd_args = NULL; scoped_refptr<ServiceWorkerContextWrapper> context; @@ -609,10 +609,9 @@ void ServiceWorkerInternalsUI::DispatchPushEvent( void ServiceWorkerInternalsUI::InspectWorker(const ListValue* args) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); int callback_id; - int process_id; - int devtools_agent_route_id; const DictionaryValue* cmd_args = NULL; - scoped_refptr<ServiceWorkerContextWrapper> context; + int process_id = 0; + int devtools_agent_route_id = 0; if (!args->GetInteger(0, &callback_id) || !args->GetDictionary(1, &cmd_args) || !cmd_args->GetInteger("process_id", &process_id) || |