From 88b591f24cb3f94f982d7024c2e8ed25c2cc26a2 Mon Sep 17 00:00:00 2001 From: Alex Vakulenko Date: Thu, 28 Aug 2014 16:48:57 -0700 Subject: [PATCH] update_engine: Replace NULL with nullptr Replaced the usage of NULL with nullptr. This also makes it possible to use standard gtest macros to compare pointers in Update Manager's unit tests. So, there is no need in custom UMTEST_... macros which are replaced with the gtest macros (see change in update_engine/update_manager/umtest_utils.h): UMTEST_ASSERT_NULL(p) => ASSERT_EQ(nullptr, p) UMTEST_ASSERT_NOT_NULL(p) => ASSERT_NE(nullptr, p) UMTEST_EXPECT_NULL(p) => EXPECT_EQ(nullptr, p) UMTEST_EXPECT_NOT_NULL(p) => EXPECT_NE(nullptr, p) BUG=None TEST=FEATURES=test emerge-link update_engine USE="clang asan" FEATURES=test emerge-link update_engine Change-Id: I77a42a1e9ce992bb2f9f263db5cf75fe6110a4ec Reviewed-on: https://chromium-review.googlesource.com/215136 Tested-by: Alex Vakulenko Reviewed-by: Alex Deymo Commit-Queue: Alex Vakulenko --- action.h | 2 +- action_processor.cc | 12 +- action_processor.h | 6 +- action_processor_unittest.cc | 14 +- bzip_extent_writer_unittest.cc | 4 +- certificate_checker.cc | 8 +- certificate_checker_unittest.cc | 14 +- chrome_browser_proxy_resolver.cc | 20 +- connection_manager.cc | 23 +- connection_manager_unittest.cc | 32 +- dbus_service.cc | 8 +- delta_performer.cc | 6 +- delta_performer_unittest.cc | 26 +- download_action.cc | 12 +- download_action_unittest.cc | 26 +- extent_writer_unittest.cc | 2 +- fake_p2p_manager_configuration.h | 2 +- fake_prefs.cc | 2 +- file_writer_unittest.cc | 4 +- filesystem_copier_action.cc | 18 +- filesystem_copier_action.h | 2 +- filesystem_copier_action_unittest.cc | 8 +- glib_utils.cc | 2 +- glib_utils.h | 2 +- hardware.cc | 2 +- http_common.cc | 4 +- http_fetcher.cc | 6 +- http_fetcher.h | 6 +- http_fetcher_unittest.cc | 20 +- libcurl_http_fetcher.cc | 16 +- libcurl_http_fetcher.h | 10 +- mock_http_fetcher.cc | 12 +- mock_http_fetcher.h | 4 +- omaha_hash_calculator.cc | 6 +- omaha_hash_calculator_unittest.cc | 4 +- omaha_request_action.cc | 12 +- omaha_request_action.h | 8 +- omaha_request_action_unittest.cc | 458 +++++++++--------- omaha_request_params.cc | 16 +- omaha_request_params.h | 2 +- omaha_request_params_unittest.cc | 2 +- omaha_response_handler_action_unittest.cc | 4 +- p2p_manager.cc | 64 +-- p2p_manager.h | 6 +- p2p_manager_unittest.cc | 24 +- payload_generator/delta_diff_generator.cc | 20 +- .../delta_diff_generator_unittest.cc | 16 +- .../filesystem_iterator_unittest.cc | 6 +- payload_generator/full_update_generator.cc | 15 +- .../full_update_generator_unittest.cc | 4 +- payload_generator/generate_delta_main.cc | 4 +- payload_generator/metadata.cc | 4 +- payload_generator/metadata_unittest.cc | 14 +- payload_generator/payload_signer.cc | 9 +- payload_generator/payload_signer_unittest.cc | 2 +- payload_state.cc | 2 +- payload_verifier.cc | 6 +- postinstall_runner_action.cc | 4 +- postinstall_runner_action.h | 6 +- postinstall_runner_action_unittest.cc | 4 +- real_system_state.cc | 2 +- subprocess.cc | 46 +- subprocess.h | 6 +- subprocess_unittest.cc | 4 +- test_http_server.cc | 2 +- test_utils.cc | 2 +- test_utils.h | 4 +- update_attempter.cc | 40 +- update_attempter_unittest.cc | 76 +-- update_check_scheduler.cc | 2 +- update_check_scheduler_unittest.cc | 14 +- update_engine_client.cc | 52 +- update_manager/boxed_value.h | 8 +- update_manager/boxed_value_unittest.cc | 4 +- update_manager/evaluation_context.cc | 2 +- update_manager/evaluation_context.h | 2 +- update_manager/evaluation_context_unittest.cc | 29 +- update_manager/fake_variable.h | 7 +- update_manager/generic_variables_unittest.cc | 10 +- .../real_config_provider_unittest.cc | 2 +- update_manager/real_random_provider.cc | 2 +- .../real_random_provider_unittest.cc | 8 +- update_manager/real_shill_provider.cc | 14 +- update_manager/real_shill_provider.h | 4 +- .../real_shill_provider_unittest.cc | 2 +- .../real_system_provider_unittest.cc | 6 +- update_manager/real_time_provider_unittest.cc | 2 +- update_manager/real_updater_provider.cc | 26 +- .../real_updater_provider_unittest.cc | 2 +- update_manager/state_factory.cc | 2 +- update_manager/umtest_utils.h | 24 +- update_manager/update_manager.h | 4 +- update_manager/variable.h | 4 +- utils.cc | 19 +- utils.h | 14 +- utils_unittest.cc | 4 +- 96 files changed, 750 insertions(+), 758 deletions(-) diff --git a/action.h b/action.h index 27f1af9..c7fcba6 100644 --- a/action.h +++ b/action.h @@ -70,7 +70,7 @@ namespace chromeos_update_engine { // It is handy to have a non-templated base class of all Actions. class AbstractAction { public: - AbstractAction() : processor_(NULL) {} + AbstractAction() : processor_(nullptr) {} // Begin performing the action. Since this code is asynchronous, when this // method returns, it means only that the action has started, not necessarily diff --git a/action_processor.cc b/action_processor.cc index e3862c4..5e08a5f 100644 --- a/action_processor.cc +++ b/action_processor.cc @@ -12,7 +12,7 @@ using std::string; namespace chromeos_update_engine { ActionProcessor::ActionProcessor() - : current_action_(NULL), delegate_(NULL) {} + : current_action_(nullptr), delegate_(nullptr) {} ActionProcessor::~ActionProcessor() { if (IsRunning()) { @@ -20,7 +20,7 @@ ActionProcessor::~ActionProcessor() { } for (std::deque::iterator it = actions_.begin(); it != actions_.end(); ++it) { - (*it)->SetProcessor(NULL); + (*it)->SetProcessor(nullptr); } } @@ -45,10 +45,10 @@ void ActionProcessor::StopProcessing() { CHECK(current_action_); current_action_->TerminateProcessing(); CHECK(current_action_); - current_action_->SetProcessor(NULL); + current_action_->SetProcessor(nullptr); LOG(INFO) << "ActionProcessor::StopProcessing: aborted " << current_action_->Type(); - current_action_ = NULL; + current_action_ = nullptr; if (delegate_) delegate_->ProcessingStopped(this); } @@ -60,8 +60,8 @@ void ActionProcessor::ActionComplete(AbstractAction* actionptr, delegate_->ActionCompleted(this, actionptr, code); string old_type = current_action_->Type(); current_action_->ActionCompleted(code); - current_action_->SetProcessor(NULL); - current_action_ = NULL; + current_action_->SetProcessor(nullptr); + current_action_ = nullptr; if (actions_.empty()) { LOG(INFO) << "ActionProcessor::ActionComplete: finished last action of" " type " << old_type; diff --git a/action_processor.h b/action_processor.h index adc4781..cb1aeb2 100644 --- a/action_processor.h +++ b/action_processor.h @@ -43,12 +43,12 @@ class ActionProcessor { void StopProcessing(); // Returns true iff an Action is currently processing. - bool IsRunning() const { return NULL != current_action_; } + bool IsRunning() const { return nullptr != current_action_; } // Adds another Action to the end of the queue. virtual void EnqueueAction(AbstractAction* action); - // Sets/gets the current delegate. Set to NULL to remove a delegate. + // Sets/gets the current delegate. Set to null to remove a delegate. ActionProcessorDelegate* delegate() const { return delegate_; } void set_delegate(ActionProcessorDelegate *delegate) { delegate_ = delegate; @@ -70,7 +70,7 @@ class ActionProcessor { // A pointer to the currently processing Action, if any. AbstractAction* current_action_; - // A pointer to the delegate, or NULL if none. + // A pointer to the delegate, or null if none. ActionProcessorDelegate *delegate_; DISALLOW_COPY_AND_ASSIGN(ActionProcessor); }; diff --git a/action_processor_unittest.cc b/action_processor_unittest.cc index 78968ef..cde1eec 100644 --- a/action_processor_unittest.cc +++ b/action_processor_unittest.cc @@ -105,7 +105,7 @@ TEST(ActionProcessorTest, DelegateTest) { action_processor.EnqueueAction(&action); action_processor.StartProcessing(); action.CompleteAction(); - action_processor.set_delegate(NULL); + action_processor.set_delegate(nullptr); EXPECT_TRUE(delegate.processing_done_called_); EXPECT_TRUE(delegate.action_completed_called_); } @@ -119,11 +119,11 @@ TEST(ActionProcessorTest, StopProcessingTest) { action_processor.EnqueueAction(&action); action_processor.StartProcessing(); action_processor.StopProcessing(); - action_processor.set_delegate(NULL); + action_processor.set_delegate(nullptr); EXPECT_TRUE(delegate.processing_stopped_called_); EXPECT_FALSE(delegate.action_completed_called_); EXPECT_FALSE(action_processor.IsRunning()); - EXPECT_EQ(NULL, action_processor.current_action()); + EXPECT_EQ(nullptr, action_processor.current_action()); } TEST(ActionProcessorTest, ChainActionsTest) { @@ -138,7 +138,7 @@ TEST(ActionProcessorTest, ChainActionsTest) { EXPECT_EQ(&action2, action_processor.current_action()); EXPECT_TRUE(action_processor.IsRunning()); action2.CompleteAction(); - EXPECT_EQ(NULL, action_processor.current_action()); + EXPECT_EQ(nullptr, action_processor.current_action()); EXPECT_FALSE(action_processor.IsRunning()); } @@ -150,9 +150,9 @@ TEST(ActionProcessorTest, DtorTest) { action_processor.EnqueueAction(&action2); action_processor.StartProcessing(); } - EXPECT_EQ(NULL, action1.processor()); + EXPECT_EQ(nullptr, action1.processor()); EXPECT_FALSE(action1.IsRunning()); - EXPECT_EQ(NULL, action2.processor()); + EXPECT_EQ(nullptr, action2.processor()); EXPECT_FALSE(action2.IsRunning()); } @@ -171,7 +171,7 @@ TEST(ActionProcessorTest, DefaultDelegateTest) { action_processor.StartProcessing(); action_processor.StopProcessing(); - action_processor.set_delegate(NULL); + action_processor.set_delegate(nullptr); } } // namespace chromeos_update_engine diff --git a/bzip_extent_writer_unittest.cc b/bzip_extent_writer_unittest.cc index 185c201..fb4d90b 100644 --- a/bzip_extent_writer_unittest.cc +++ b/bzip_extent_writer_unittest.cc @@ -77,10 +77,10 @@ TEST_F(BzipExtentWriterTest, ChunkedTest) { const vector::size_type kDecompressedLength = 2048 * 1024; // 2 MiB string decompressed_path; ASSERT_TRUE(utils::MakeTempFile("BzipExtentWriterTest-decompressed-XXXXXX", - &decompressed_path, NULL)); + &decompressed_path, nullptr)); string compressed_path; ASSERT_TRUE(utils::MakeTempFile("BzipExtentWriterTest-compressed-XXXXXX", - &compressed_path, NULL)); + &compressed_path, nullptr)); const size_t kChunkSize = 3; vector extents; diff --git a/certificate_checker.cc b/certificate_checker.cc index a774900..4dd9182 100644 --- a/certificate_checker.cc +++ b/certificate_checker.cc @@ -52,10 +52,10 @@ bool OpenSSLWrapper::GetCertificateDigest(X509_STORE_CTX* x509_ctx, } // static -SystemState* CertificateChecker::system_state_ = NULL; +SystemState* CertificateChecker::system_state_ = nullptr; // static -OpenSSLWrapper* CertificateChecker::openssl_wrapper_ = NULL; +OpenSSLWrapper* CertificateChecker::openssl_wrapper_ = nullptr; // static CURLcode CertificateChecker::ProcessSSLContext(CURL* curl_handle, @@ -103,8 +103,8 @@ bool CertificateChecker::CheckCertificateChange( static const char kUMAActionCertChanged[] = "Updater.ServerCertificateChanged"; static const char kUMAActionCertFailed[] = "Updater.ServerCertificateFailed"; - TEST_AND_RETURN_FALSE(system_state_ != NULL); - TEST_AND_RETURN_FALSE(system_state_->prefs() != NULL); + TEST_AND_RETURN_FALSE(system_state_ != nullptr); + TEST_AND_RETURN_FALSE(system_state_->prefs() != nullptr); TEST_AND_RETURN_FALSE(server_to_check != kNone); // If pre-verification failed, we are not interested in the current diff --git a/certificate_checker_unittest.cc b/certificate_checker_unittest.cc index 4469c0f..ef9bbd2 100644 --- a/certificate_checker_unittest.cc +++ b/certificate_checker_unittest.cc @@ -72,7 +72,7 @@ class CertificateCheckerTest : public testing::Test { // check certificate change, new TEST_F(CertificateCheckerTest, NewCertificate) { - EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(NULL, _, _, _)) + EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(nullptr, _, _, _)) .WillOnce(DoAll( SetArgumentPointee<1>(depth_), SetArgumentPointee<2>(length_), @@ -83,12 +83,12 @@ TEST_F(CertificateCheckerTest, NewCertificate) { EXPECT_CALL(*prefs_, SetString(cert_key_, digest_hex_)) .WillOnce(Return(true)); ASSERT_TRUE(CertificateChecker::CheckCertificateChange( - server_to_check_, 1, NULL)); + server_to_check_, 1, nullptr)); } // check certificate change, unchanged TEST_F(CertificateCheckerTest, SameCertificate) { - EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(NULL, _, _, _)) + EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(nullptr, _, _, _)) .WillOnce(DoAll( SetArgumentPointee<1>(depth_), SetArgumentPointee<2>(length_), @@ -100,12 +100,12 @@ TEST_F(CertificateCheckerTest, SameCertificate) { Return(true))); EXPECT_CALL(*prefs_, SetString(_, _)).Times(0); ASSERT_TRUE(CertificateChecker::CheckCertificateChange( - server_to_check_, 1, NULL)); + server_to_check_, 1, nullptr)); } // check certificate change, changed TEST_F(CertificateCheckerTest, ChangedCertificate) { - EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(NULL, _, _, _)) + EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(nullptr, _, _, _)) .WillOnce(DoAll( SetArgumentPointee<1>(depth_), SetArgumentPointee<2>(length_), @@ -121,7 +121,7 @@ TEST_F(CertificateCheckerTest, ChangedCertificate) { EXPECT_CALL(*prefs_, SetString(cert_key_, digest_hex_)) .WillOnce(Return(true)); ASSERT_TRUE(CertificateChecker::CheckCertificateChange( - server_to_check_, 1, NULL)); + server_to_check_, 1, nullptr)); } // check certificate change, failed @@ -132,7 +132,7 @@ TEST_F(CertificateCheckerTest, FailedCertificate) { EXPECT_CALL(*prefs_, GetString(_, _)).Times(0); EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(_, _, _, _)).Times(0); ASSERT_FALSE(CertificateChecker::CheckCertificateChange( - server_to_check_, 0, NULL)); + server_to_check_, 0, nullptr)); } // flush send report diff --git a/chrome_browser_proxy_resolver.cc b/chrome_browser_proxy_resolver.cc index 4ee1679..85646f8 100644 --- a/chrome_browser_proxy_resolver.cc +++ b/chrome_browser_proxy_resolver.cc @@ -53,14 +53,14 @@ const int kTimeout = 5; // seconds ChromeBrowserProxyResolver::ChromeBrowserProxyResolver( DBusWrapperInterface* dbus) - : dbus_(dbus), proxy_(NULL), timeout_(kTimeout) {} + : dbus_(dbus), proxy_(nullptr), timeout_(kTimeout) {} bool ChromeBrowserProxyResolver::Init() { if (proxy_) return true; // Already initialized. // Set up signal handler. Code lifted from libcros. - GError* g_error = NULL; + GError* g_error = nullptr; DBusGConnection* bus = dbus_->BusGet(DBUS_BUS_SYSTEM, &g_error); TEST_AND_RETURN_FALSE(bus); DBusConnection* connection = dbus_->ConnectionGetConnection(bus); @@ -75,7 +75,7 @@ bool ChromeBrowserProxyResolver::Init() { connection, &ChromeBrowserProxyResolver::StaticFilterMessage, this, - NULL)); + nullptr)); proxy_ = dbus_->ProxyNewForName(bus, kLibCrosServiceName, kLibCrosServicePath, kLibCrosServiceInterface); @@ -92,7 +92,7 @@ bool ChromeBrowserProxyResolver::Init() { ChromeBrowserProxyResolver::~ChromeBrowserProxyResolver() { // Remove DBus connection filters and Kill proxy object. if (proxy_) { - GError* gerror = NULL; + GError* gerror = nullptr; DBusGConnection* gbus = dbus_->BusGet(DBUS_BUS_SYSTEM, &gerror); if (gbus) { DBusConnection* connection = dbus_->ConnectionGetConnection(gbus); @@ -108,14 +108,14 @@ ChromeBrowserProxyResolver::~ChromeBrowserProxyResolver() { for (TimeoutsMap::iterator it = timers_.begin(), e = timers_.end(); it != e; ++it) { g_source_destroy(it->second); - it->second = NULL; + it->second = nullptr; } } bool ChromeBrowserProxyResolver::GetProxiesForUrl(const string& url, ProxiesResolvedFn callback, void* data) { - GError* error = NULL; + GError* error = nullptr; guint timeout = timeout_; if (proxy_) { if (!dbus_->ProxyCall_3_0(proxy_, @@ -146,7 +146,7 @@ bool ChromeBrowserProxyResolver::GetProxiesForUrl(const string& url, GSource* timer = g_timeout_source_new_seconds(timeout); g_source_set_callback( timer, utils::GlibRunClosure, closure, utils::GlibDestroyClosure); - g_source_attach(timer, NULL); + g_source_attach(timer, nullptr); timers_.insert(make_pair(url, timer)); return true; } @@ -161,9 +161,9 @@ DBusHandlerResult ChromeBrowserProxyResolver::FilterMessage( return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } // Get args - char* source_url = NULL; - char* proxy_list = NULL; - char* error = NULL; + char* source_url = nullptr; + char* proxy_list = nullptr; + char* error = nullptr; DBusError arg_error; dbus_error_init(&arg_error); if (!dbus_->DBusMessageGetArgs_3(message, &arg_error, diff --git a/connection_manager.cc b/connection_manager.cc index b5daa14..f6c0217 100644 --- a/connection_manager.cc +++ b/connection_manager.cc @@ -32,7 +32,7 @@ bool GetFlimFlamProxy(DBusWrapperInterface* dbus_iface, DBusGProxy** out_proxy) { DBusGConnection* bus; DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; bus = dbus_iface->BusGet(DBUS_BUS_SYSTEM, &error); if (!bus) { @@ -52,7 +52,7 @@ bool GetProperties(DBusWrapperInterface* dbus_iface, const char* interface, GHashTable** out_hash_table) { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; TEST_AND_RETURN_FALSE(GetFlimFlamProxy(dbus_iface, path, @@ -76,7 +76,7 @@ bool GetProperties(DBusWrapperInterface* dbus_iface, // there's no network up. // Returns true on success. bool GetDefaultServicePath(DBusWrapperInterface* dbus_iface, string* out_path) { - GHashTable* hash_table = NULL; + GHashTable* hash_table = nullptr; TEST_AND_RETURN_FALSE(GetProperties(dbus_iface, shill::kFlimflamServicePath, @@ -85,7 +85,7 @@ bool GetDefaultServicePath(DBusWrapperInterface* dbus_iface, string* out_path) { GValue* value = reinterpret_cast(g_hash_table_lookup(hash_table, "Services")); - GPtrArray* array = NULL; + GPtrArray* array = nullptr; bool success = false; if (G_VALUE_HOLDS(value, DBUS_TYPE_G_OBJECT_PATH_ARRAY) && (array = reinterpret_cast(g_value_get_boxed(value))) && @@ -129,7 +129,7 @@ bool GetServicePathProperties(DBusWrapperInterface* dbus_iface, const string& path, NetworkConnectionType* out_type, NetworkTethering* out_tethering) { - GHashTable* hash_table = NULL; + GHashTable* hash_table = nullptr; TEST_AND_RETURN_FALSE(GetProperties(dbus_iface, path.c_str(), @@ -140,11 +140,11 @@ bool GetServicePathProperties(DBusWrapperInterface* dbus_iface, GValue* value = reinterpret_cast(g_hash_table_lookup(hash_table, shill::kTetheringProperty)); - const char* tethering_str = NULL; + const char* tethering_str = nullptr; - if (value != NULL) + if (value != nullptr) tethering_str = g_value_get_string(value); - if (tethering_str != NULL) { + if (tethering_str != nullptr) { *out_tethering = ParseTethering(tethering_str); } else { // Set to Unknown if not present. @@ -154,14 +154,15 @@ bool GetServicePathProperties(DBusWrapperInterface* dbus_iface, // Populate the out_type property. value = reinterpret_cast(g_hash_table_lookup(hash_table, shill::kTypeProperty)); - const char* type_str = NULL; + const char* type_str = nullptr; bool success = false; - if (value != NULL && (type_str = g_value_get_string(value)) != NULL) { + if (value != nullptr && (type_str = g_value_get_string(value)) != nullptr) { success = true; if (!strcmp(type_str, shill::kTypeVPN)) { value = reinterpret_cast( g_hash_table_lookup(hash_table, shill::kPhysicalTechnologyProperty)); - if (value != NULL && (type_str = g_value_get_string(value)) != NULL) { + if (value != nullptr && + (type_str = g_value_get_string(value)) != nullptr) { *out_type = ParseConnectionType(type_str); } else { LOG(ERROR) << "No PhysicalTechnology property found for a VPN" diff --git a/connection_manager_unittest.cc b/connection_manager_unittest.cc index ca6e256..47adf11 100644 --- a/connection_manager_unittest.cc +++ b/connection_manager_unittest.cc @@ -28,9 +28,9 @@ namespace chromeos_update_engine { class ConnectionManagerTest : public ::testing::Test { public: ConnectionManagerTest() - : kMockFlimFlamManagerProxy_(NULL), - kMockFlimFlamServiceProxy_(NULL), - kServicePath_(NULL), + : kMockFlimFlamManagerProxy_(nullptr), + kMockFlimFlamServiceProxy_(nullptr), + kServicePath_(nullptr), cmut_(&fake_system_state_) { fake_system_state_.set_connection_manager(&cmut_); } @@ -40,7 +40,7 @@ class ConnectionManagerTest : public ::testing::Test { void SetManagerReply(const char* reply_value, const GType& reply_type); // Sets the |service_type| Type and the |physical_technology| - // PhysicalTechnology properties in the mocked service. If a NULL + // PhysicalTechnology properties in the mocked service. If a null // |physical_technology| is passed, the property is not set (not present). void SetServiceReply(const char* service_type, const char* physical_technology, @@ -71,7 +71,7 @@ void ConnectionManagerTest::SetupMocks(const char* service_path) { kMockSystemBus_ = reinterpret_cast(number++); kMockFlimFlamManagerProxy_ = reinterpret_cast(number++); kMockFlimFlamServiceProxy_ = reinterpret_cast(number++); - ASSERT_NE(kMockSystemBus_, reinterpret_cast(NULL)); + ASSERT_NE(kMockSystemBus_, static_cast(nullptr)); kServicePath_ = service_path; @@ -91,7 +91,7 @@ void ConnectionManagerTest::SetManagerReply(const char *reply_value, // of the GPtrArray automatically when the |array_as_value| GValue is unset. // The g_strdup() is not being leaked. GPtrArray* array = g_ptr_array_new(); - ASSERT_TRUE(array != NULL); + ASSERT_NE(nullptr, array); g_ptr_array_add(array, g_strdup(reply_value)); GValue* array_as_value = g_new0(GValue, 1); @@ -140,14 +140,14 @@ void ConnectionManagerTest::SetServiceReply(const char* service_type, const_cast("Type"), service_type_value); - if (physical_technology != NULL) { + if (physical_technology) { GValue* physical_technology_value = GValueNewString(physical_technology); g_hash_table_insert(service_hash_table, const_cast("PhysicalTechnology"), physical_technology_value); } - if (service_tethering != NULL) { + if (service_tethering) { GValue* service_tethering_value = GValueNewString(service_tethering); g_hash_table_insert(service_hash_table, const_cast("Tethering"), @@ -195,7 +195,7 @@ void ConnectionManagerTest::TestWithServiceTethering( SetupMocks("/service/guest-network"); SetManagerReply(kServicePath_, DBUS_TYPE_G_OBJECT_PATH_ARRAY); - SetServiceReply(shill::kTypeWifi, NULL, service_tethering); + SetServiceReply(shill::kTypeWifi, nullptr, service_tethering); NetworkConnectionType type; NetworkTethering tethering; @@ -204,15 +204,15 @@ void ConnectionManagerTest::TestWithServiceTethering( } TEST_F(ConnectionManagerTest, SimpleTest) { - TestWithServiceType(shill::kTypeEthernet, NULL, kNetEthernet); - TestWithServiceType(shill::kTypeWifi, NULL, kNetWifi); - TestWithServiceType(shill::kTypeWimax, NULL, kNetWimax); - TestWithServiceType(shill::kTypeBluetooth, NULL, kNetBluetooth); - TestWithServiceType(shill::kTypeCellular, NULL, kNetCellular); + TestWithServiceType(shill::kTypeEthernet, nullptr, kNetEthernet); + TestWithServiceType(shill::kTypeWifi, nullptr, kNetWifi); + TestWithServiceType(shill::kTypeWimax, nullptr, kNetWimax); + TestWithServiceType(shill::kTypeBluetooth, nullptr, kNetBluetooth); + TestWithServiceType(shill::kTypeCellular, nullptr, kNetCellular); } TEST_F(ConnectionManagerTest, PhysicalTechnologyTest) { - TestWithServiceType(shill::kTypeVPN, NULL, kNetUnknown); + TestWithServiceType(shill::kTypeVPN, nullptr, kNetUnknown); TestWithServiceType(shill::kTypeVPN, shill::kTypeVPN, kNetUnknown); TestWithServiceType(shill::kTypeVPN, shill::kTypeWifi, kNetWifi); TestWithServiceType(shill::kTypeVPN, shill::kTypeWimax, kNetWimax); @@ -230,7 +230,7 @@ TEST_F(ConnectionManagerTest, TetheringTest) { } TEST_F(ConnectionManagerTest, UnknownTest) { - TestWithServiceType("foo", NULL, kNetUnknown); + TestWithServiceType("foo", nullptr, kNetUnknown); } TEST_F(ConnectionManagerTest, AllowUpdatesOverEthernetTest) { diff --git a/dbus_service.cc b/dbus_service.cc index a8e1dcd..36ee494 100644 --- a/dbus_service.cc +++ b/dbus_service.cc @@ -97,9 +97,9 @@ static void update_engine_service_class_init(UpdateEngineServiceClass* klass) { G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, 0, // 0 == no class method associated - NULL, // Accumulator - NULL, // Accumulator data - NULL, // Marshaller + nullptr, // Accumulator + nullptr, // Accumulator data + nullptr, // Marshaller G_TYPE_NONE, // Return type 5, // param count: G_TYPE_INT64, @@ -117,7 +117,7 @@ static void update_engine_service_init(UpdateEngineService* object) { UpdateEngineService* update_engine_service_new(void) { return reinterpret_cast( - g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL)); + g_object_new(UPDATE_ENGINE_TYPE_SERVICE, nullptr)); } gboolean update_engine_service_attempt_update(UpdateEngineService* self, diff --git a/delta_performer.cc b/delta_performer.cc index a22adfb..ce44be5 100644 --- a/delta_performer.cc +++ b/delta_performer.cc @@ -594,7 +594,7 @@ bool DeltaPerformer::PerformReplaceOperation( // Since bzip decompression is optional, we have a variable writer that will // point to one of the ExtentWriter objects above. - ExtentWriter* writer = NULL; + ExtentWriter* writer = nullptr; if (operation.type() == DeltaArchiveManifest_InstallOperation_Type_REPLACE) { writer = &zero_pad_writer; } else if (operation.type() == @@ -744,7 +744,7 @@ bool DeltaPerformer::PerformBsdiffOperation( string temp_filename; TEST_AND_RETURN_FALSE(utils::MakeTempFile("/tmp/au_patch.XXXXXX", &temp_filename, - NULL)); + nullptr)); ScopedPathUnlinker path_unlinker(temp_filename); { int fd = open(temp_filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644); @@ -780,7 +780,7 @@ bool DeltaPerformer::PerformBsdiffOperation( Subprocess::SynchronousExecFlags(cmd, G_SPAWN_LEAVE_DESCRIPTORS_OPEN, &return_code, - NULL)); + nullptr)); TEST_AND_RETURN_FALSE(return_code == 0); if (operation.dst_length() % block_size_) { diff --git a/delta_performer_unittest.cc b/delta_performer_unittest.cc index d68aa25..8b640e8 100644 --- a/delta_performer_unittest.cc +++ b/delta_performer_unittest.cc @@ -185,7 +185,7 @@ static void SignGeneratedShellPayload(SignatureTest signature_test, if (signature_test == kSignatureGeneratedShellBadKey) { ASSERT_TRUE(utils::MakeTempFile("key.XXXXXX", &private_key_path, - NULL)); + nullptr)); } else { ASSERT_TRUE(signature_test == kSignatureGeneratedShell || signature_test == kSignatureGeneratedShellRotateCl1 || @@ -203,7 +203,7 @@ static void SignGeneratedShellPayload(SignatureTest signature_test, } int signature_size = GetSignatureSize(private_key_path); string hash_file; - ASSERT_TRUE(utils::MakeTempFile("hash.XXXXXX", &hash_file, NULL)); + ASSERT_TRUE(utils::MakeTempFile("hash.XXXXXX", &hash_file, nullptr)); ScopedPathUnlinker hash_unlinker(hash_file); string signature_size_string; if (signature_test == kSignatureGeneratedShellRotateCl1 || @@ -227,7 +227,7 @@ static void SignGeneratedShellPayload(SignatureTest signature_test, ASSERT_TRUE(WriteFileVector(hash_file, hash)); string sig_file; - ASSERT_TRUE(utils::MakeTempFile("signature.XXXXXX", &sig_file, NULL)); + ASSERT_TRUE(utils::MakeTempFile("signature.XXXXXX", &sig_file, nullptr)); ScopedPathUnlinker sig_unlinker(sig_file); ASSERT_EQ(0, System(base::StringPrintf( @@ -237,7 +237,7 @@ static void SignGeneratedShellPayload(SignatureTest signature_test, hash_file.c_str(), sig_file.c_str()))); string sig_file2; - ASSERT_TRUE(utils::MakeTempFile("signature.XXXXXX", &sig_file2, NULL)); + ASSERT_TRUE(utils::MakeTempFile("signature.XXXXXX", &sig_file2, nullptr)); ScopedPathUnlinker sig2_unlinker(sig_file2); if (signature_test == kSignatureGeneratedShellRotateCl1 || signature_test == kSignatureGeneratedShellRotateCl2) { @@ -279,9 +279,9 @@ static void GenerateDeltaFile(bool full_kernel, off_t chunk_size, SignatureTest signature_test, DeltaState *state) { - EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &state->a_img, NULL)); - EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &state->b_img, NULL)); - CreateExtImageAtPath(state->a_img, NULL); + EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &state->a_img, nullptr)); + EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &state->b_img, nullptr)); + CreateExtImageAtPath(state->a_img, nullptr); state->image_size = static_cast(utils::FileSize(state->a_img)); @@ -357,7 +357,7 @@ static void GenerateDeltaFile(bool full_kernel, base::FilePath(state->b_img))); old_image_info = new_image_info; } else { - CreateExtImageAtPath(state->b_img, NULL); + CreateExtImageAtPath(state->b_img, nullptr); EXPECT_EQ(0, System(base::StringPrintf( "dd if=/dev/zero of=%s seek=%d bs=1 count=1", state->b_img.c_str(), @@ -428,12 +428,12 @@ static void GenerateDeltaFile(bool full_kernel, string old_kernel; EXPECT_TRUE(utils::MakeTempFile("old_kernel.XXXXXX", &state->old_kernel, - NULL)); + nullptr)); string new_kernel; EXPECT_TRUE(utils::MakeTempFile("new_kernel.XXXXXX", &state->new_kernel, - NULL)); + nullptr)); state->old_kernel_data.resize(kDefaultKernelSize); state->new_kernel_data.resize(state->old_kernel_data.size()); @@ -457,7 +457,7 @@ static void GenerateDeltaFile(bool full_kernel, EXPECT_TRUE(utils::MakeTempFile("delta.XXXXXX", &state->delta_path, - NULL)); + nullptr)); LOG(INFO) << "delta path: " << state->delta_path; { string a_mnt, b_mnt; @@ -477,7 +477,7 @@ static void GenerateDeltaFile(bool full_kernel, private_key, chunk_size, kRootFSPartitionSize, - full_rootfs ? NULL : &old_image_info, + full_rootfs ? nullptr : &old_image_info, &new_image_info, &state->metadata_size)); } @@ -732,7 +732,7 @@ void VerifyPayloadResult(DeltaPerformer* performer, DeltaState* state, ErrorCode expected_result) { if (!performer) { - EXPECT_TRUE(!"Skipping payload verification since performer is NULL."); + EXPECT_TRUE(!"Skipping payload verification since performer is null."); return; } diff --git a/download_action.cc b/download_action.cc index 0d4354b..5b3ffeb 100644 --- a/download_action.cc +++ b/download_action.cc @@ -32,9 +32,9 @@ DownloadAction::DownloadAction(PrefsInterface* prefs, : prefs_(prefs), system_state_(system_state), http_fetcher_(http_fetcher), - writer_(NULL), + writer_(nullptr), code_(ErrorCode::kSuccess), - delegate_(NULL), + delegate_(nullptr), bytes_received_(0), p2p_sharing_fd_(-1), p2p_visible_(true) {} @@ -188,7 +188,7 @@ void DownloadAction::PerformAction() { delegate_->SetDownloadStatus(true); // Set to active. } - if (system_state_ != NULL) { + if (system_state_ != nullptr) { string file_id = utils::CalculateP2PFileId(install_plan_.payload_hash, install_plan_.payload_size); if (system_state_->request_params()->use_p2p_for_sharing()) { @@ -216,7 +216,7 @@ void DownloadAction::PerformAction() { // Tweak timeouts on the HTTP fetcher if we're downloading from a // local peer. - if (system_state_ != NULL && + if (system_state_ != nullptr && system_state_->request_params()->use_p2p_for_downloading() && system_state_->request_params()->p2p_url() == install_plan_.download_url) { @@ -233,7 +233,7 @@ void DownloadAction::PerformAction() { void DownloadAction::TerminateProcessing() { if (writer_) { writer_->Close(); - writer_ = NULL; + writer_ = nullptr; } if (delegate_) { delegate_->SetDownloadStatus(false); // Set to inactive. @@ -285,7 +285,7 @@ void DownloadAction::ReceivedBytes(HttpFetcher *fetcher, void DownloadAction::TransferComplete(HttpFetcher *fetcher, bool successful) { if (writer_) { LOG_IF(WARNING, writer_->Close() != 0) << "Error closing the writer."; - writer_ = NULL; + writer_ = nullptr; } if (delegate_) { delegate_->SetDownloadStatus(false); // Set to inactive. diff --git a/download_action_unittest.cc b/download_action_unittest.cc index e061782..97dd0f3 100644 --- a/download_action_unittest.cc +++ b/download_action_unittest.cc @@ -48,7 +48,7 @@ class DownloadActionDelegateMock : public DownloadActionDelegate { class DownloadActionTestProcessorDelegate : public ActionProcessorDelegate { public: explicit DownloadActionTestProcessorDelegate(ErrorCode expected_code) - : loop_(NULL), + : loop_(nullptr), processing_done_called_(false), expected_code_(expected_code) {} virtual ~DownloadActionTestProcessorDelegate() { @@ -156,9 +156,9 @@ void TestWithData(const vector& data, PrefsMock prefs; MockHttpFetcher* http_fetcher = new MockHttpFetcher(&data[0], data.size(), - NULL); + nullptr); // takes ownership of passed in HttpFetcher - DownloadAction download_action(&prefs, NULL, http_fetcher); + DownloadAction download_action(&prefs, nullptr, http_fetcher); download_action.SetTestFileWriter(&writer); BondActions(&feeder_action, &download_action); DownloadActionDelegateMock download_delegate; @@ -269,10 +269,10 @@ void TestTerminateEarly(bool use_download_delegate) { temp_file.GetPath(), "", ""); feeder_action.set_obj(install_plan); PrefsMock prefs; - DownloadAction download_action(&prefs, NULL, + DownloadAction download_action(&prefs, nullptr, new MockHttpFetcher(&data[0], data.size(), - NULL)); + nullptr)); download_action.SetTestFileWriter(&writer); DownloadActionDelegateMock download_delegate; if (use_download_delegate) { @@ -380,8 +380,8 @@ TEST(DownloadActionTest, PassObjectOutTest) { ObjectFeederAction feeder_action; feeder_action.set_obj(install_plan); PrefsMock prefs; - DownloadAction download_action(&prefs, NULL, - new MockHttpFetcher("x", 1, NULL)); + DownloadAction download_action(&prefs, nullptr, + new MockHttpFetcher("x", 1, nullptr)); download_action.SetTestFileWriter(&writer); DownloadActionTestAction test_action; @@ -415,8 +415,8 @@ TEST(DownloadActionTest, BadOutFileTest) { ObjectFeederAction feeder_action; feeder_action.set_obj(install_plan); PrefsMock prefs; - DownloadAction download_action(&prefs, NULL, - new MockHttpFetcher("x", 1, NULL)); + DownloadAction download_action(&prefs, nullptr, + new MockHttpFetcher("x", 1, nullptr)); download_action.SetTestFileWriter(&writer); BondActions(&feeder_action, &download_action); @@ -440,7 +440,7 @@ gboolean StartProcessorInRunLoopForP2P(gpointer user_data) { class P2PDownloadActionTest : public testing::Test { protected: P2PDownloadActionTest() - : loop_(NULL), + : loop_(nullptr), start_at_offset_(0) {} virtual ~P2PDownloadActionTest() {} @@ -452,7 +452,7 @@ class P2PDownloadActionTest : public testing::Test { // Derived from testing::Test. virtual void TearDown() { - if (loop_ != NULL) + if (loop_ != nullptr) g_main_loop_unref(loop_); } @@ -467,7 +467,7 @@ class P2PDownloadActionTest : public testing::Test { // Setup p2p. FakeP2PManagerConfiguration *test_conf = new FakeP2PManagerConfiguration(); - p2p_manager_.reset(P2PManager::Construct(test_conf, NULL, "cros_au", 3)); + p2p_manager_.reset(P2PManager::Construct(test_conf, nullptr, "cros_au", 3)); fake_system_state_.set_p2p_manager(p2p_manager_.get()); } @@ -495,7 +495,7 @@ class P2PDownloadActionTest : public testing::Test { PrefsMock prefs; http_fetcher_ = new MockHttpFetcher(data_.c_str(), data_.length(), - NULL); + nullptr); // Note that DownloadAction takes ownership of the passed in HttpFetcher. download_action_.reset(new DownloadAction(&prefs, &fake_system_state_, http_fetcher_)); diff --git a/extent_writer_unittest.cc b/extent_writer_unittest.cc index fcd57dd..fef3343 100644 --- a/extent_writer_unittest.cc +++ b/extent_writer_unittest.cc @@ -92,7 +92,7 @@ TEST_F(ExtentWriterTest, ZeroLengthTest) { DirectExtentWriter direct_writer; EXPECT_TRUE(direct_writer.Init(fd(), extents, kBlockSize)); - EXPECT_TRUE(direct_writer.Write(NULL, 0)); + EXPECT_TRUE(direct_writer.Write(nullptr, 0)); EXPECT_TRUE(direct_writer.End()); } diff --git a/fake_p2p_manager_configuration.h b/fake_p2p_manager_configuration.h index 8756630..0645d7a 100644 --- a/fake_p2p_manager_configuration.h +++ b/fake_p2p_manager_configuration.h @@ -98,7 +98,7 @@ class FakeP2PManagerConfiguration : public P2PManager::Configuration { if (!g_shell_parse_argv(command_line.c_str(), &argc, &argv, - NULL)) { + nullptr)) { LOG(ERROR) << "Error splitting '" << command_line << "'"; return ret; } diff --git a/fake_prefs.cc b/fake_prefs.cc index e26b865..653104e 100644 --- a/fake_prefs.cc +++ b/fake_prefs.cc @@ -15,7 +15,7 @@ namespace { void CheckNotNull(const string& key, void* ptr) { EXPECT_NE(nullptr, ptr) - << "Called Get*() for key \"" << key << "\" with a NULL parameter."; + << "Called Get*() for key \"" << key << "\" with a null parameter."; } } // namespace diff --git a/file_writer_unittest.cc b/file_writer_unittest.cc index 5d24eab..8f4ab9e 100644 --- a/file_writer_unittest.cc +++ b/file_writer_unittest.cc @@ -26,7 +26,7 @@ class FileWriterTest : public ::testing::Test { }; TEST(FileWriterTest, SimpleTest) { // Create a uniquely named file for testing. string path; - ASSERT_TRUE(utils::MakeTempFile("FileWriterTest-XXXXXX", &path, NULL)); + ASSERT_TRUE(utils::MakeTempFile("FileWriterTest-XXXXXX", &path, nullptr)); ScopedPathUnlinker path_unlinker(path); DirectFileWriter file_writer; @@ -51,7 +51,7 @@ TEST(FileWriterTest, ErrorTest) { TEST(FileWriterTest, WriteErrorTest) { // Create a uniquely named file for testing. string path; - ASSERT_TRUE(utils::MakeTempFile("FileWriterTest-XXXXXX", &path, NULL)); + ASSERT_TRUE(utils::MakeTempFile("FileWriterTest-XXXXXX", &path, nullptr)); ScopedPathUnlinker path_unlinker(path); DirectFileWriter file_writer; diff --git a/filesystem_copier_action.cc b/filesystem_copier_action.cc index efd454d..a8f56e9 100644 --- a/filesystem_copier_action.cc +++ b/filesystem_copier_action.cc @@ -43,8 +43,8 @@ FilesystemCopierAction::FilesystemCopierAction( bool verify_hash) : copying_kernel_install_path_(copying_kernel_install_path), verify_hash_(verify_hash), - src_stream_(NULL), - dst_stream_(NULL), + src_stream_(nullptr), + dst_stream_(nullptr), read_done_(false), failed_(false), cancelled_(false), @@ -60,7 +60,7 @@ FilesystemCopierAction::FilesystemCopierAction( for (int i = 0; i < 2; ++i) { buffer_state_[i] = kBufferStateEmpty; buffer_valid_size_[i] = 0; - canceller_[i] = NULL; + canceller_[i] = nullptr; } } @@ -154,19 +154,19 @@ void FilesystemCopierAction::TerminateProcessing() { } bool FilesystemCopierAction::IsCleanupPending() const { - return (src_stream_ != NULL); + return (src_stream_ != nullptr); } void FilesystemCopierAction::Cleanup(ErrorCode code) { for (int i = 0; i < 2; i++) { g_object_unref(canceller_[i]); - canceller_[i] = NULL; + canceller_[i] = nullptr; } g_object_unref(src_stream_); - src_stream_ = NULL; + src_stream_ = nullptr; if (dst_stream_) { g_object_unref(dst_stream_); - dst_stream_ = NULL; + dst_stream_ = nullptr; } if (cancelled_) return; @@ -180,7 +180,7 @@ void FilesystemCopierAction::AsyncReadReadyCallback(GObject *source_object, int index = buffer_state_[0] == kBufferStateReading ? 0 : 1; CHECK(buffer_state_[index] == kBufferStateReading); - GError* error = NULL; + GError* error = nullptr; CHECK(canceller_[index]); cancelled_ = g_cancellable_is_cancelled(canceller_[index]) == TRUE; @@ -227,7 +227,7 @@ void FilesystemCopierAction::AsyncWriteReadyCallback(GObject *source_object, CHECK(buffer_state_[index] == kBufferStateWriting); buffer_state_[index] = kBufferStateEmpty; - GError* error = NULL; + GError* error = nullptr; CHECK(canceller_[index]); cancelled_ = g_cancellable_is_cancelled(canceller_[index]) == TRUE; diff --git a/filesystem_copier_action.h b/filesystem_copier_action.h index cdb3d8b..4ebe905 100644 --- a/filesystem_copier_action.h +++ b/filesystem_copier_action.h @@ -100,7 +100,7 @@ class FilesystemCopierAction : public InstallPlanAction { // passed in InstallPlan. std::string copy_source_; - // If non-NULL, these are GUnixInputStream objects for the opened + // If non-null, these are GUnixInputStream objects for the opened // source/destination partitions. GInputStream* src_stream_; GOutputStream* dst_stream_; diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc index 024b743..131feb8 100644 --- a/filesystem_copier_action_unittest.cc +++ b/filesystem_copier_action_unittest.cc @@ -132,8 +132,8 @@ bool FilesystemCopierActionTest::DoTest(bool run_out_of_space, string a_loop_file; string b_loop_file; - if (!(utils::MakeTempFile("a_loop_file.XXXXXX", &a_loop_file, NULL) && - utils::MakeTempFile("b_loop_file.XXXXXX", &b_loop_file, NULL))) { + if (!(utils::MakeTempFile("a_loop_file.XXXXXX", &a_loop_file, nullptr) && + utils::MakeTempFile("b_loop_file.XXXXXX", &b_loop_file, nullptr))) { ADD_FAILURE(); return false; } @@ -406,9 +406,9 @@ TEST_F(FilesystemCopierActionTest, RunAsRootTerminateEarlyTest) { TEST_F(FilesystemCopierActionTest, RunAsRootDetermineFilesystemSizeTest) { string img; - EXPECT_TRUE(utils::MakeTempFile("img.XXXXXX", &img, NULL)); + EXPECT_TRUE(utils::MakeTempFile("img.XXXXXX", &img, nullptr)); ScopedPathUnlinker img_unlinker(img); - CreateExtImageAtPath(img, NULL); + CreateExtImageAtPath(img, nullptr); // Extend the "partition" holding the file system from 10MiB to 20MiB. EXPECT_EQ(0, System(base::StringPrintf( "dd if=/dev/zero of=%s seek=20971519 bs=1 count=1", diff --git a/glib_utils.cc b/glib_utils.cc index 523a16f..3371da4 100644 --- a/glib_utils.cc +++ b/glib_utils.cc @@ -20,7 +20,7 @@ string GetAndFreeGError(GError** error) { (*error)->code, (*error)->message ? (*error)->message : "(unknown)"); g_error_free(*error); - *error = NULL; + *error = nullptr; return message; } diff --git a/glib_utils.h b/glib_utils.h index 9fea076..0c941ca 100644 --- a/glib_utils.h +++ b/glib_utils.h @@ -13,7 +13,7 @@ namespace chromeos_update_engine { namespace utils { // Returns the error message, if any, from a GError pointer. Frees the GError -// object and resets error to NULL. +// object and resets error to null. std::string GetAndFreeGError(GError** error); } // namespace utils diff --git a/hardware.cc b/hardware.cc index a83d1b3..74de45a 100644 --- a/hardware.cc +++ b/hardware.cc @@ -169,7 +169,7 @@ static string ReadValueFromCrosSystem(const string& key) { const char *rv = VbGetSystemPropertyString(key.c_str(), value_buffer, sizeof(value_buffer)); - if (rv != NULL) { + if (rv != nullptr) { string return_value(value_buffer); base::TrimWhitespaceASCII(return_value, base::TRIM_ALL, &return_value); return return_value; diff --git a/http_common.cc b/http_common.cc index a3bd7f8..8cdc6eb 100644 --- a/http_common.cc +++ b/http_common.cc @@ -50,7 +50,7 @@ const char *GetHttpResponseDescription(HttpResponseCode code) { } HttpResponseCode StringToHttpResponseCode(const char *s) { - return static_cast(strtoul(s, NULL, 10)); + return static_cast(strtoul(s, nullptr, 10)); } @@ -68,7 +68,7 @@ const char *GetHttpContentTypeString(HttpContentType type) { if ((is_found = (http_content_type_table[i].type == type))) break; - return (is_found ? http_content_type_table[i].str : NULL); + return (is_found ? http_content_type_table[i].str : nullptr); } } // namespace chromeos_update_engine diff --git a/http_fetcher.cc b/http_fetcher.cc index 7fa2812..91aa177 100644 --- a/http_fetcher.cc +++ b/http_fetcher.cc @@ -41,7 +41,7 @@ bool HttpFetcher::ResolveProxiesForUrl(const string& url, Closure* callback) { utils::GlibDestroyClosure); return true; } - CHECK_EQ(reinterpret_cast(NULL), callback_); + CHECK_EQ(static_cast(nullptr), callback_); callback_ = callback; return proxy_resolver_->GetProxiesForUrl(url, &HttpFetcher::StaticProxiesResolved, @@ -52,9 +52,9 @@ void HttpFetcher::ProxiesResolved(const std::deque& proxies) { no_resolver_idle_id_ = 0; if (!proxies.empty()) SetProxies(proxies); - CHECK_NE(reinterpret_cast(NULL), callback_); + CHECK_NE(static_cast(nullptr), callback_); Closure* callback = callback_; - callback_ = NULL; + callback_ = nullptr; // This may indirectly call back into ResolveProxiesForUrl(): callback->Run(); delete callback; diff --git a/http_fetcher.h b/http_fetcher.h index bab19d9..9c92abb 100644 --- a/http_fetcher.h +++ b/http_fetcher.h @@ -37,11 +37,11 @@ class HttpFetcher { HttpFetcher(ProxyResolver* proxy_resolver, SystemState* system_state) : post_data_set_(false), http_response_code_(0), - delegate_(NULL), + delegate_(nullptr), proxies_(1, kNoProxy), proxy_resolver_(proxy_resolver), no_resolver_idle_id_(0), - callback_(NULL), + callback_(nullptr), system_state_(system_state) {} virtual ~HttpFetcher(); @@ -137,7 +137,7 @@ class HttpFetcher { // set to the response code when the transfer is complete. int http_response_code_; - // The delegate; may be NULL. + // The delegate; may be null. HttpFetcherDelegate* delegate_; // Proxy servers diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc index 3879bc4..ec074d7 100644 --- a/http_fetcher_unittest.cc +++ b/http_fetcher_unittest.cc @@ -95,11 +95,13 @@ class PythonHttpServer : public HttpServer { // Spawn the server process. gchar *argv[] = { const_cast("./test_http_server"), - NULL }; + nullptr + }; GError *err; gint server_stdout = -1; - if (!g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, - NULL, NULL, &pid_, NULL, &server_stdout, NULL, + if (!g_spawn_async_with_pipes(nullptr, argv, nullptr, + G_SPAWN_DO_NOT_REAP_CHILD, nullptr, nullptr, + &pid_, nullptr, &server_stdout, nullptr, &err)) { LOG(ERROR) << "failed to spawn http server process"; return; @@ -612,8 +614,8 @@ TYPED_TEST(HttpFetcherTest, AbortTest) { GSource* timeout_source_; timeout_source_ = g_timeout_source_new(0); // ms g_source_set_callback(timeout_source_, AbortingTimeoutCallback, &delegate, - NULL); - g_source_attach(timeout_source_, NULL); + nullptr); + g_source_attach(timeout_source_, nullptr); delegate.fetcher_->BeginTransfer(this->test_.BigUrl(server->GetPort())); g_main_loop_run(loop); @@ -686,7 +688,7 @@ namespace { class FailureHttpFetcherTestDelegate : public HttpFetcherDelegate { public: explicit FailureHttpFetcherTestDelegate(PythonHttpServer* server) - : loop_(NULL), + : loop_(nullptr), server_(server) {} virtual ~FailureHttpFetcherTestDelegate() { @@ -703,7 +705,7 @@ class FailureHttpFetcherTestDelegate : public HttpFetcherDelegate { LOG(INFO) << "Stopping server in ReceivedBytes"; delete server_; LOG(INFO) << "server stopped"; - server_ = NULL; + server_ = nullptr; } } virtual void TransferComplete(HttpFetcher* fetcher, bool successful) { @@ -727,7 +729,7 @@ TYPED_TEST(HttpFetcherTest, FailureTest) { return; GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); { - FailureHttpFetcherTestDelegate delegate(NULL); + FailureHttpFetcherTestDelegate delegate(nullptr); delegate.loop_ = loop; scoped_ptr fetcher(this->test_.NewSmallFetcher()); fetcher->set_delegate(&delegate); @@ -906,7 +908,7 @@ class MultiHttpFetcherTestDelegate : public HttpFetcherDelegate { if (expected_response_code_ != 0) EXPECT_EQ(expected_response_code_, fetcher->http_response_code()); // Destroy the fetcher (because we're allowed to). - fetcher_.reset(NULL); + fetcher_.reset(nullptr); g_main_loop_quit(loop_); } diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc index da643bf..64680c1 100644 --- a/libcurl_http_fetcher.cc +++ b/libcurl_http_fetcher.cc @@ -105,7 +105,8 @@ void LibcurlHttpFetcher::ResumeTransfer(const std::string& url) { const string content_type_attr = base::StringPrintf("Content-Type: %s", GetHttpContentTypeString(post_content_type_)); - curl_http_headers_ = curl_slist_append(NULL, content_type_attr.c_str()); + curl_http_headers_ = curl_slist_append(nullptr, + content_type_attr.c_str()); CHECK(curl_http_headers_); CHECK_EQ( curl_easy_setopt(curl_handle_, CURLOPT_HTTPHEADER, @@ -476,8 +477,9 @@ void LibcurlHttpFetcher::SetupMainloopSources() { if (!timeout_source_) { LOG(INFO) << "Setting up timeout source: " << idle_seconds_ << " seconds."; timeout_source_ = g_timeout_source_new_seconds(idle_seconds_); - g_source_set_callback(timeout_source_, StaticTimeoutCallback, this, NULL); - g_source_attach(timeout_source_, NULL); + g_source_set_callback(timeout_source_, StaticTimeoutCallback, this, + nullptr); + g_source_attach(timeout_source_, nullptr); } } @@ -510,7 +512,7 @@ gboolean LibcurlHttpFetcher::TimeoutCallback() { void LibcurlHttpFetcher::CleanUp() { if (timeout_source_) { g_source_destroy(timeout_source_); - timeout_source_ = NULL; + timeout_source_ = nullptr; } for (size_t t = 0; t < arraysize(io_channels_); ++t) { @@ -524,7 +526,7 @@ void LibcurlHttpFetcher::CleanUp() { if (curl_http_headers_) { curl_slist_free_all(curl_http_headers_); - curl_http_headers_ = NULL; + curl_http_headers_ = nullptr; } if (curl_handle_) { if (curl_multi_handle_) { @@ -532,11 +534,11 @@ void LibcurlHttpFetcher::CleanUp() { CURLM_OK); } curl_easy_cleanup(curl_handle_); - curl_handle_ = NULL; + curl_handle_ = nullptr; } if (curl_multi_handle_) { CHECK_EQ(curl_multi_cleanup(curl_multi_handle_), CURLM_OK); - curl_multi_handle_ = NULL; + curl_multi_handle_ = nullptr; } transfer_in_progress_ = false; } diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h index 495a2a9..c59ca05 100644 --- a/libcurl_http_fetcher.h +++ b/libcurl_http_fetcher.h @@ -30,10 +30,10 @@ class LibcurlHttpFetcher : public HttpFetcher { LibcurlHttpFetcher(ProxyResolver* proxy_resolver, SystemState* system_state) : HttpFetcher(proxy_resolver, system_state), - curl_multi_handle_(NULL), - curl_handle_(NULL), - curl_http_headers_(NULL), - timeout_source_(NULL), + curl_multi_handle_(nullptr), + curl_handle_(nullptr), + curl_http_headers_(nullptr), + timeout_source_(nullptr), transfer_in_progress_(false), transfer_size_(0), bytes_downloaded_(0), @@ -218,7 +218,7 @@ class LibcurlHttpFetcher : public HttpFetcher { typedef std::map> IOChannels; IOChannels io_channels_[2]; - // if non-NULL, a timer we're waiting on. glib main loop will call us back + // if non-null, a timer we're waiting on. glib main loop will call us back // when it fires. GSource* timeout_source_; diff --git a/mock_http_fetcher.cc b/mock_http_fetcher.cc index 9b3ae86..e178a50 100644 --- a/mock_http_fetcher.cc +++ b/mock_http_fetcher.cc @@ -31,7 +31,7 @@ void MockHttpFetcher::BeginTransfer(const std::string& url) { } // Returns false on one condition: If timeout_source_ was already set -// and it needs to be deleted by the caller. If timeout_source_ is NULL +// and it needs to be deleted by the caller. If timeout_source_ is null // when this function is called, this function will always return true. bool MockHttpFetcher::SendData(bool skip_delivery) { if (fail_transfer_) { @@ -72,8 +72,8 @@ bool MockHttpFetcher::SendData(bool skip_delivery) { timeout_source_ = g_timeout_source_new(10); CHECK(timeout_source_); g_source_set_callback(timeout_source_, StaticTimeoutCallback, this, - NULL); - timout_tag_ = g_source_attach(timeout_source_, NULL); + nullptr); + timout_tag_ = g_source_attach(timeout_source_, nullptr); } return true; } @@ -82,7 +82,7 @@ bool MockHttpFetcher::TimeoutCallback() { CHECK(!paused_); bool ret = SendData(false); if (false == ret) { - timeout_source_ = NULL; + timeout_source_ = nullptr; } return ret; } @@ -96,7 +96,7 @@ void MockHttpFetcher::TerminateTransfer() { if (timeout_source_) { g_source_remove(timout_tag_); g_source_destroy(timeout_source_); - timeout_source_ = NULL; + timeout_source_ = nullptr; } delegate_->TransferTerminated(this); } @@ -107,7 +107,7 @@ void MockHttpFetcher::Pause() { if (timeout_source_) { g_source_remove(timout_tag_); g_source_destroy(timeout_source_); - timeout_source_ = NULL; + timeout_source_ = nullptr; } } diff --git a/mock_http_fetcher.h b/mock_http_fetcher.h index 748acf1..4bf1685 100644 --- a/mock_http_fetcher.h +++ b/mock_http_fetcher.h @@ -36,7 +36,7 @@ class MockHttpFetcher : public HttpFetcher { ProxyResolver* proxy_resolver) : HttpFetcher(proxy_resolver, &fake_system_state_), sent_size_(0), - timeout_source_(NULL), + timeout_source_(nullptr), timout_tag_(0), paused_(false), fail_transfer_(false), @@ -120,7 +120,7 @@ class MockHttpFetcher : public HttpFetcher { // time out for 0s just to make sure that run loop services other clients. GSource* timeout_source_; - // ID of the timeout source, valid only if timeout_source_ != NULL + // ID of the timeout source, valid only if timeout_source_ != null guint timout_tag_; // True iff the fetcher is paused. diff --git a/omaha_hash_calculator.cc b/omaha_hash_calculator.cc index 1b61a9d..af39611 100644 --- a/omaha_hash_calculator.cc +++ b/omaha_hash_calculator.cc @@ -46,7 +46,7 @@ class ScopedBioHandle { void FreeCurrentBio() { if (bio_) { BIO_free_all(bio_); - bio_ = NULL; + bio_ = nullptr; } } @@ -114,13 +114,13 @@ bool OmahaHashCalculator::Base64Encode(const void* data, if (success) success = (BIO_flush(b64) == 1); - BUF_MEM *bptr = NULL; + BUF_MEM *bptr = nullptr; BIO_get_mem_ptr(b64, &bptr); out->assign(bptr->data, bptr->length - 1); } if (b64) { BIO_free_all(b64); - b64 = NULL; + b64 = nullptr; } return success; } diff --git a/omaha_hash_calculator_unittest.cc b/omaha_hash_calculator_unittest.cc index 93a7125..762a528 100644 --- a/omaha_hash_calculator_unittest.cc +++ b/omaha_hash_calculator_unittest.cc @@ -103,7 +103,7 @@ TEST_F(OmahaHashCalculatorTest, BigTest) { TEST_F(OmahaHashCalculatorTest, UpdateFileSimpleTest) { string data_path; ASSERT_TRUE( - utils::MakeTempFile("data.XXXXXX", &data_path, NULL)); + utils::MakeTempFile("data.XXXXXX", &data_path, nullptr)); ScopedPathUnlinker data_path_unlinker(data_path); ASSERT_TRUE(utils::WriteFile(data_path.c_str(), "hi", 2)); @@ -128,7 +128,7 @@ TEST_F(OmahaHashCalculatorTest, UpdateFileSimpleTest) { TEST_F(OmahaHashCalculatorTest, RawHashOfFileSimpleTest) { string data_path; ASSERT_TRUE( - utils::MakeTempFile("data.XXXXXX", &data_path, NULL)); + utils::MakeTempFile("data.XXXXXX", &data_path, nullptr)); ScopedPathUnlinker data_path_unlinker(data_path); ASSERT_TRUE(utils::WriteFile(data_path.c_str(), "hi", 2)); diff --git a/omaha_request_action.cc b/omaha_request_action.cc index 1bd5041..ede4e64 100644 --- a/omaha_request_action.cc +++ b/omaha_request_action.cc @@ -101,7 +101,7 @@ string GetAppBody(const OmahaEvent* event, int ping_roll_call_days, PrefsInterface* prefs) { string app_body; - if (event == NULL) { + if (event == nullptr) { app_body = GetPingXml(ping_active_days, ping_roll_call_days); if (!ping_only) { // not passing update_disabled to Omaha because we want to @@ -428,7 +428,7 @@ void OmahaRequestAction::InitPingDays() { // static int OmahaRequestAction::GetInstallDate(SystemState* system_state) { PrefsInterface* prefs = system_state->prefs(); - if (prefs == NULL) + if (prefs == nullptr) return -1; // If we have the value stored on disk, just return it. @@ -935,7 +935,7 @@ void OmahaRequestAction::LookupPayloadViaP2P(const OmahaResponse& response) { int64_t manifest_metadata_size = 0; int64_t next_data_offset = 0; int64_t next_data_length = 0; - if (system_state_ != NULL && + if (system_state_ && system_state_->prefs()->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size) && manifest_metadata_size != -1 && @@ -948,7 +948,7 @@ void OmahaRequestAction::LookupPayloadViaP2P(const OmahaResponse& response) { } string file_id = utils::CalculateP2PFileId(response.hash, response.size); - if (system_state_->p2p_manager() != NULL) { + if (system_state_->p2p_manager()) { LOG(INFO) << "Checking if payload is available via p2p, file_id=" << file_id << " minimum_size=" << minimum_size; system_state_->p2p_manager()->LookupUrlForFile( @@ -1190,7 +1190,7 @@ bool OmahaRequestAction::ParseInstallDate(OmahaParserData* parser_data, // static bool OmahaRequestAction::HasInstallDate(SystemState *system_state) { PrefsInterface* prefs = system_state->prefs(); - if (prefs == NULL) + if (prefs == nullptr) return false; return prefs->Exists(kPrefsInstallDateDays); @@ -1204,7 +1204,7 @@ bool OmahaRequestAction::PersistInstallDate( TEST_AND_RETURN_FALSE(install_date_days >= 0); PrefsInterface* prefs = system_state->prefs(); - if (prefs == NULL) + if (prefs == nullptr) return false; if (!prefs->SetInt64(kPrefsInstallDateDays, install_date_days)) diff --git a/omaha_request_action.h b/omaha_request_action.h index 0dc3d9f..a4d9fdf 100644 --- a/omaha_request_action.h +++ b/omaha_request_action.h @@ -112,14 +112,14 @@ class OmahaRequestAction : public Action, // // Takes ownership of the passed in HttpFetcher. Useful for testing. // - // Takes ownership of the passed in OmahaEvent. If |event| is NULL, + // Takes ownership of the passed in OmahaEvent. If |event| is null, // this is an UpdateCheck request, otherwise it's an Event request. // Event requests always succeed. // // A good calling pattern is: // OmahaRequestAction(..., new OmahaEvent(...), new WhateverHttpFetcher); // or - // OmahaRequestAction(..., NULL, new WhateverHttpFetcher); + // OmahaRequestAction(..., nullptr, new WhateverHttpFetcher); OmahaRequestAction(SystemState* system_state, OmahaEvent* event, HttpFetcher* http_fetcher, @@ -143,7 +143,7 @@ class OmahaRequestAction : public Action, virtual void TransferComplete(HttpFetcher *fetcher, bool successful); // Returns true if this is an Event request, false if it's an UpdateCheck. - bool IsEvent() const { return event_.get() != NULL; } + bool IsEvent() const { return event_.get() != nullptr; } private: FRIEND_TEST(OmahaRequestActionTest, GetInstallDate); @@ -264,7 +264,7 @@ class OmahaRequestAction : public Action, // Contains state that is relevant in the processing of the Omaha request. OmahaRequestParams* params_; - // Pointer to the OmahaEvent info. This is an UpdateCheck request if NULL. + // Pointer to the OmahaEvent info. This is an UpdateCheck request if null. scoped_ptr event_; // pointer to the HttpFetcher that does the http work diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc index 6d960e2..572721d 100644 --- a/omaha_request_action_unittest.cc +++ b/omaha_request_action_unittest.cc @@ -159,7 +159,7 @@ string GetUpdateResponse(const string& app_id, class OmahaRequestActionTestProcessorDelegate : public ActionProcessorDelegate { public: OmahaRequestActionTestProcessorDelegate() - : loop_(NULL), + : loop_(nullptr), expected_code_(ErrorCode::kSuccess) {} virtual ~OmahaRequestActionTestProcessorDelegate() { } @@ -224,11 +224,11 @@ class OutputObjectCollectorAction : public Action { }; // Returns true iff an output response was obtained from the -// OmahaRequestAction. |prefs| may be NULL, in which case a local PrefsMock is -// used. |payload_state| may be NULL, in which case a local mock is used. -// |p2p_manager| may be NULL, in which case a local mock is used. -// |connection_manager| may be NULL, in which case a local mock is used. -// out_response may be NULL. If |fail_http_response_code| is non-negative, +// OmahaRequestAction. |prefs| may be null, in which case a local PrefsMock +// is used. |payload_state| may be null, in which case a local mock is used. +// |p2p_manager| may be null, in which case a local mock is used. +// |connection_manager| may be null, in which case a local mock is used. +// out_response may be null. If |fail_http_response_code| is non-negative, // the transfer will fail with that code. |ping_only| is passed through to the // OmahaRequestAction constructor. out_post_data may be null; if non-null, the // post-data received by the mock HttpFetcher is returned. @@ -255,7 +255,7 @@ bool TestUpdateCheck(PrefsInterface* prefs, GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), http_response.size(), - NULL); + nullptr); if (fail_http_response_code >= 0) { fetcher->FailTransfer(fail_http_response_code); } @@ -270,7 +270,7 @@ bool TestUpdateCheck(PrefsInterface* prefs, fake_system_state.set_connection_manager(connection_manager); fake_system_state.set_request_params(params); OmahaRequestAction action(&fake_system_state, - NULL, + nullptr, fetcher, ping_only); OmahaRequestActionTestProcessorDelegate delegate; @@ -323,7 +323,7 @@ void TestEvent(OmahaRequestParams params, GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), http_response.size(), - NULL); + nullptr); FakeSystemState fake_system_state; fake_system_state.set_request_params(¶ms); OmahaRequestAction action(&fake_system_state, event, fetcher, false); @@ -343,10 +343,10 @@ void TestEvent(OmahaRequestParams params, TEST(OmahaRequestActionTest, RejectEntities) { OmahaResponse response; ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetNoUpdateResponseWithEntity(OmahaRequestParams::kAppId), -1, @@ -356,17 +356,17 @@ TEST(OmahaRequestActionTest, RejectEntities) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } TEST(OmahaRequestActionTest, NoUpdateTest) { OmahaResponse response; ASSERT_TRUE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetNoUpdateResponse(OmahaRequestParams::kAppId), -1, @@ -376,17 +376,17 @@ TEST(OmahaRequestActionTest, NoUpdateTest) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } TEST(OmahaRequestActionTest, ValidUpdateTest) { OmahaResponse response; ASSERT_TRUE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetUpdateResponse(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -405,7 +405,7 @@ TEST(OmahaRequestActionTest, ValidUpdateTest) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); EXPECT_TRUE(response.update_exists); EXPECT_EQ("1.2.3.4", response.version); @@ -422,10 +422,10 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByPolicyTest) { OmahaRequestParams params = kDefaultTestParams; params.set_update_disabled(true); ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -444,7 +444,7 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByPolicyTest) { metrics::CheckReaction::kIgnored, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } @@ -452,7 +452,7 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByConnection) { OmahaResponse response; // Set up a connection manager that doesn't allow a valid update over // the current ethernet connection. - MockConnectionManager mock_cm(NULL); + MockConnectionManager mock_cm(nullptr); EXPECT_CALL(mock_cm, GetConnectionProperties(_, _, _)) .WillRepeatedly(DoAll(SetArgumentPointee<1>(kNetEthernet), SetArgumentPointee<2>(NetworkTethering::kUnknown), @@ -463,9 +463,9 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByConnection) { .WillRepeatedly(Return(shill::kTypeEthernet)); ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager &mock_cm, // connection_manager &kDefaultTestParams, GetUpdateResponse(OmahaRequestParams::kAppId, @@ -485,7 +485,7 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByConnection) { metrics::CheckReaction::kIgnored, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } @@ -498,10 +498,10 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByRollback) { .WillRepeatedly(Return(rollback_version)); ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs + TestUpdateCheck(nullptr, // prefs &mock_payload_state, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetUpdateResponse(OmahaRequestParams::kAppId, rollback_version, // version @@ -520,7 +520,7 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByRollback) { metrics::CheckReaction::kIgnored, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } @@ -529,10 +529,10 @@ TEST(OmahaRequestActionTest, NoUpdatesSentWhenBlockedByPolicyTest) { OmahaRequestParams params = kDefaultTestParams; params.set_update_disabled(true); ASSERT_TRUE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetNoUpdateResponse(OmahaRequestParams::kAppId), -1, @@ -542,7 +542,7 @@ TEST(OmahaRequestActionTest, NoUpdatesSentWhenBlockedByPolicyTest) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } @@ -564,9 +564,9 @@ TEST(OmahaRequestActionTest, WallClockBasedWaitAloneCausesScattering) { ASSERT_FALSE( TestUpdateCheck(&prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -589,16 +589,16 @@ TEST(OmahaRequestActionTest, WallClockBasedWaitAloneCausesScattering) { metrics::CheckReaction::kDeferring, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); // Verify if we are interactive check we don't defer. params.set_interactive(true); ASSERT_TRUE( TestUpdateCheck(&prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -621,7 +621,7 @@ TEST(OmahaRequestActionTest, WallClockBasedWaitAloneCausesScattering) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); } @@ -646,9 +646,9 @@ TEST(OmahaRequestActionTest, NoWallClockBasedWaitCausesNoScattering) { ASSERT_TRUE( TestUpdateCheck(&prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -671,7 +671,7 @@ TEST(OmahaRequestActionTest, NoWallClockBasedWaitCausesNoScattering) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); } @@ -696,9 +696,9 @@ TEST(OmahaRequestActionTest, ZeroMaxDaysToScatterCausesNoScattering) { ASSERT_TRUE( TestUpdateCheck(&prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -721,7 +721,7 @@ TEST(OmahaRequestActionTest, ZeroMaxDaysToScatterCausesNoScattering) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); } @@ -747,9 +747,9 @@ TEST(OmahaRequestActionTest, ZeroUpdateCheckCountCausesNoScattering) { ASSERT_TRUE(TestUpdateCheck( &prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -772,7 +772,7 @@ TEST(OmahaRequestActionTest, ZeroUpdateCheckCountCausesNoScattering) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); int64_t count; ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count)); @@ -801,9 +801,9 @@ TEST(OmahaRequestActionTest, NonZeroUpdateCheckCountCausesScattering) { ASSERT_FALSE(TestUpdateCheck( &prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -826,7 +826,7 @@ TEST(OmahaRequestActionTest, NonZeroUpdateCheckCountCausesScattering) { metrics::CheckReaction::kDeferring, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); int64_t count; ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count)); @@ -837,9 +837,9 @@ TEST(OmahaRequestActionTest, NonZeroUpdateCheckCountCausesScattering) { params.set_interactive(true); ASSERT_TRUE( TestUpdateCheck(&prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -862,7 +862,7 @@ TEST(OmahaRequestActionTest, NonZeroUpdateCheckCountCausesScattering) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); } @@ -889,9 +889,9 @@ TEST(OmahaRequestActionTest, ExistingUpdateCheckCountCausesScattering) { ASSERT_FALSE(TestUpdateCheck( &prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -914,7 +914,7 @@ TEST(OmahaRequestActionTest, ExistingUpdateCheckCountCausesScattering) { metrics::CheckReaction::kDeferring, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); int64_t count; ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count)); @@ -927,9 +927,9 @@ TEST(OmahaRequestActionTest, ExistingUpdateCheckCountCausesScattering) { params.set_interactive(true); ASSERT_TRUE( TestUpdateCheck(&prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -952,7 +952,7 @@ TEST(OmahaRequestActionTest, ExistingUpdateCheckCountCausesScattering) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); } @@ -964,10 +964,10 @@ TEST(OmahaRequestActionTest, NoOutputPipeTest) { FakeSystemState fake_system_state; OmahaRequestParams params = kDefaultTestParams; fake_system_state.set_request_params(¶ms); - OmahaRequestAction action(&fake_system_state, NULL, + OmahaRequestAction action(&fake_system_state, nullptr, new MockHttpFetcher(http_response.data(), http_response.size(), - NULL), + nullptr), false); OmahaRequestActionTestProcessorDelegate delegate; delegate.loop_ = loop; @@ -984,10 +984,10 @@ TEST(OmahaRequestActionTest, NoOutputPipeTest) { TEST(OmahaRequestActionTest, InvalidXmlTest) { OmahaResponse response; ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "invalid xml>", -1, @@ -997,17 +997,17 @@ TEST(OmahaRequestActionTest, InvalidXmlTest) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } TEST(OmahaRequestActionTest, EmptyResponseTest) { OmahaResponse response; ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "", -1, @@ -1017,17 +1017,17 @@ TEST(OmahaRequestActionTest, EmptyResponseTest) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } TEST(OmahaRequestActionTest, MissingStatusTest) { OmahaResponse response; ASSERT_FALSE(TestUpdateCheck( - NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "" "" @@ -1041,17 +1041,17 @@ TEST(OmahaRequestActionTest, MissingStatusTest) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } TEST(OmahaRequestActionTest, InvalidStatusTest) { OmahaResponse response; ASSERT_FALSE(TestUpdateCheck( - NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "" "" @@ -1065,17 +1065,17 @@ TEST(OmahaRequestActionTest, InvalidStatusTest) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } TEST(OmahaRequestActionTest, MissingNodesetTest) { OmahaResponse response; ASSERT_FALSE(TestUpdateCheck( - NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "" "" @@ -1089,7 +1089,7 @@ TEST(OmahaRequestActionTest, MissingNodesetTest) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } @@ -1114,10 +1114,10 @@ TEST(OmahaRequestActionTest, MissingFieldTest) { LOG(INFO) << "Input Response = " << input_response; OmahaResponse response; - ASSERT_TRUE(TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + ASSERT_TRUE(TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, input_response, -1, @@ -1127,7 +1127,7 @@ TEST(OmahaRequestActionTest, MissingFieldTest) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); EXPECT_EQ("10.2.3.4", response.version); EXPECT_EQ("http://missing/field/test/f", response.payload_urls[0]); @@ -1164,10 +1164,10 @@ TEST(OmahaRequestActionTest, TerminateTransferTest) { FakeSystemState fake_system_state; OmahaRequestParams params = kDefaultTestParams; fake_system_state.set_request_params(¶ms); - OmahaRequestAction action(&fake_system_state, NULL, + OmahaRequestAction action(&fake_system_state, nullptr, new MockHttpFetcher(http_response.data(), http_response.size(), - NULL), + nullptr), false); TerminateEarlyTestProcessorDelegate delegate; delegate.loop_ = loop; @@ -1211,10 +1211,10 @@ TEST(OmahaRequestActionTest, XmlEncodeTest) { false); // use_p2p_for_sharing OmahaResponse response; ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, "invalid xml>", -1, @@ -1240,10 +1240,10 @@ TEST(OmahaRequestActionTest, XmlEncodeTest) { TEST(OmahaRequestActionTest, XmlDecodeTest) { OmahaResponse response; ASSERT_TRUE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetUpdateResponse(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -1262,7 +1262,7 @@ TEST(OmahaRequestActionTest, XmlDecodeTest) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_EQ(response.more_info_url, "testthe(string("")), Return(true))); EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, _)).Times(1); ASSERT_FALSE(TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "invalid xml>", -1, @@ -1318,7 +1318,7 @@ TEST(OmahaRequestActionTest, FormatUpdateCheckOutputTest) { metrics::CheckResult::kParsingError, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, // response + nullptr, // response &post_data)); // convert post_data to string string post_str(&post_data[0], post_data.size()); @@ -1344,9 +1344,9 @@ TEST(OmahaRequestActionTest, FormatUpdateDisabledOutputTest) { OmahaRequestParams params = kDefaultTestParams; params.set_update_disabled(true); ASSERT_FALSE(TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, "invalid xml>", -1, @@ -1355,7 +1355,7 @@ TEST(OmahaRequestActionTest, FormatUpdateDisabledOutputTest) { metrics::CheckResult::kParsingError, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, // response + nullptr, // response &post_data)); // convert post_data to string string post_str(&post_data[0], post_data.size()); @@ -1415,10 +1415,10 @@ TEST(OmahaRequestActionTest, IsEventTest) { fake_system_state.set_request_params(¶ms); OmahaRequestAction update_check_action( &fake_system_state, - NULL, + nullptr, new MockHttpFetcher(http_response.data(), http_response.size(), - NULL), + nullptr), false); EXPECT_FALSE(update_check_action.IsEvent()); @@ -1429,7 +1429,7 @@ TEST(OmahaRequestActionTest, IsEventTest) { new OmahaEvent(OmahaEvent::kTypeUpdateComplete), new MockHttpFetcher(http_response.data(), http_response.size(), - NULL), + nullptr), false); EXPECT_TRUE(event_action.IsEvent()); } @@ -1459,10 +1459,10 @@ TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) { "", // target_version_prefix false, // use_p2p_for_downloading false); // use_p2p_for_sharing - ASSERT_FALSE(TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + ASSERT_FALSE(TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, "invalid xml>", -1, @@ -1471,7 +1471,7 @@ TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) { metrics::CheckResult::kParsingError, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, + nullptr, &post_data)); // convert post_data to string string post_str(post_data.data(), post_data.size()); @@ -1507,10 +1507,10 @@ TEST(OmahaRequestActionTest, FormatInteractiveOutputTest) { "", // target_version_prefix false, // use_p2p_for_downloading false); // use_p2p_for_sharing - ASSERT_FALSE(TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + ASSERT_FALSE(TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, "invalid xml>", -1, @@ -1519,7 +1519,7 @@ TEST(OmahaRequestActionTest, FormatInteractiveOutputTest) { metrics::CheckResult::kParsingError, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, + nullptr, &post_data)); // convert post_data to string string post_str(&post_data[0], post_data.size()); @@ -1569,9 +1569,9 @@ TEST(OmahaRequestActionTest, PingTest) { vector post_data; ASSERT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetNoUpdateResponse(OmahaRequestParams::kAppId), -1, @@ -1580,7 +1580,7 @@ TEST(OmahaRequestActionTest, PingTest) { metrics::CheckResult::kUnset, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, + nullptr, &post_data)); string post_str(&post_data[0], post_data.size()); EXPECT_NE(post_str.find(""), @@ -1612,9 +1612,9 @@ TEST(OmahaRequestActionTest, ActivePingTest) { vector post_data; ASSERT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetNoUpdateResponse(OmahaRequestParams::kAppId), -1, @@ -1623,7 +1623,7 @@ TEST(OmahaRequestActionTest, ActivePingTest) { metrics::CheckResult::kNoUpdateAvailable, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, + nullptr, &post_data)); string post_str(&post_data[0], post_data.size()); EXPECT_NE(post_str.find(""), @@ -1647,9 +1647,9 @@ TEST(OmahaRequestActionTest, RollCallPingTest) { vector post_data; ASSERT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetNoUpdateResponse(OmahaRequestParams::kAppId), -1, @@ -1658,7 +1658,7 @@ TEST(OmahaRequestActionTest, RollCallPingTest) { metrics::CheckResult::kNoUpdateAvailable, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, + nullptr, &post_data)); string post_str(&post_data[0], post_data.size()); EXPECT_NE(post_str.find("\n"), @@ -1683,9 +1683,9 @@ TEST(OmahaRequestActionTest, NoPingTest) { vector post_data; ASSERT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetNoUpdateResponse(OmahaRequestParams::kAppId), -1, @@ -1694,7 +1694,7 @@ TEST(OmahaRequestActionTest, NoPingTest) { metrics::CheckResult::kNoUpdateAvailable, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, + nullptr, &post_data)); string post_str(&post_data[0], post_data.size()); EXPECT_EQ(post_str.find("ping"), string::npos); @@ -1713,9 +1713,9 @@ TEST(OmahaRequestActionTest, IgnoreEmptyPingTest) { vector post_data; EXPECT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetNoUpdateResponse(OmahaRequestParams::kAppId), -1, @@ -1724,7 +1724,7 @@ TEST(OmahaRequestActionTest, IgnoreEmptyPingTest) { metrics::CheckResult::kUnset, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, + nullptr, &post_data)); EXPECT_EQ(post_data.size(), 0); } @@ -1749,9 +1749,9 @@ TEST(OmahaRequestActionTest, BackInTimePingTest) { vector post_data; ASSERT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "" @@ -1763,7 +1763,7 @@ TEST(OmahaRequestActionTest, BackInTimePingTest) { metrics::CheckResult::kNoUpdateAvailable, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, + nullptr, &post_data)); string post_str(&post_data[0], post_data.size()); EXPECT_EQ(post_str.find("ping"), string::npos); @@ -1789,9 +1789,9 @@ TEST(OmahaRequestActionTest, LastPingDayUpdateTest) { .WillOnce(Return(true)); ASSERT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "" @@ -1803,8 +1803,8 @@ TEST(OmahaRequestActionTest, LastPingDayUpdateTest) { metrics::CheckResult::kNoUpdateAvailable, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, - NULL)); + nullptr, + nullptr)); } TEST(OmahaRequestActionTest, NoElapsedSecondsTest) { @@ -1815,9 +1815,9 @@ TEST(OmahaRequestActionTest, NoElapsedSecondsTest) { EXPECT_CALL(prefs, SetInt64(kPrefsLastRollCallPingDay, _)).Times(0); ASSERT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "" @@ -1829,8 +1829,8 @@ TEST(OmahaRequestActionTest, NoElapsedSecondsTest) { metrics::CheckResult::kNoUpdateAvailable, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, - NULL)); + nullptr, + nullptr)); } TEST(OmahaRequestActionTest, BadElapsedSecondsTest) { @@ -1841,9 +1841,9 @@ TEST(OmahaRequestActionTest, BadElapsedSecondsTest) { EXPECT_CALL(prefs, SetInt64(kPrefsLastRollCallPingDay, _)).Times(0); ASSERT_TRUE( TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "" @@ -1855,16 +1855,16 @@ TEST(OmahaRequestActionTest, BadElapsedSecondsTest) { metrics::CheckResult::kNoUpdateAvailable, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, - NULL)); + nullptr, + nullptr)); } TEST(OmahaRequestActionTest, NoUniqueIDTest) { vector post_data; - ASSERT_FALSE(TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + ASSERT_FALSE(TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "invalid xml>", -1, @@ -1873,7 +1873,7 @@ TEST(OmahaRequestActionTest, NoUniqueIDTest) { metrics::CheckResult::kParsingError, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, // response + nullptr, // response &post_data)); // convert post_data to string string post_str(&post_data[0], post_data.size()); @@ -1886,10 +1886,10 @@ TEST(OmahaRequestActionTest, NetworkFailureTest) { const int http_error_code = static_cast(ErrorCode::kOmahaRequestHTTPResponseBase) + 501; ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "", 501, @@ -1899,7 +1899,7 @@ TEST(OmahaRequestActionTest, NetworkFailureTest) { metrics::CheckReaction::kUnset, static_cast(501), &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } @@ -1908,10 +1908,10 @@ TEST(OmahaRequestActionTest, NetworkFailureBadHTTPCodeTest) { const int http_error_code = static_cast(ErrorCode::kOmahaRequestHTTPResponseBase) + 999; ASSERT_FALSE( - TestUpdateCheck(NULL, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + TestUpdateCheck(nullptr, // prefs + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, "", 1500, @@ -1921,7 +1921,7 @@ TEST(OmahaRequestActionTest, NetworkFailureBadHTTPCodeTest) { metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kHttpStatusOther, &response, - NULL)); + nullptr)); EXPECT_FALSE(response.update_exists); } @@ -1943,9 +1943,9 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsPersistedFirstTime) { ASSERT_FALSE(TestUpdateCheck( &prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -1968,7 +1968,7 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsPersistedFirstTime) { metrics::CheckReaction::kDeferring, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); int64_t timestamp = 0; ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateFirstSeenAt, ×tamp)); @@ -1979,9 +1979,9 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsPersistedFirstTime) { params.set_interactive(true); ASSERT_TRUE( TestUpdateCheck(&prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -2004,7 +2004,7 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsPersistedFirstTime) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); } @@ -2031,9 +2031,9 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsUsedIfAlreadyPresent) { ASSERT_TRUE(prefs.SetInt64(kPrefsUpdateFirstSeenAt, t1.ToInternalValue())); ASSERT_TRUE(TestUpdateCheck( &prefs, // prefs - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -2056,7 +2056,7 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsUsedIfAlreadyPresent) { metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); @@ -2095,9 +2095,9 @@ TEST(OmahaRequestActionTest, TestChangingToMoreStableChannel) { EXPECT_TRUE(params.to_more_stable_channel()); EXPECT_TRUE(params.is_powerwash_allowed()); ASSERT_FALSE(TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, "invalid xml>", -1, @@ -2106,7 +2106,7 @@ TEST(OmahaRequestActionTest, TestChangingToMoreStableChannel) { metrics::CheckResult::kParsingError, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, // response + nullptr, // response &post_data)); // convert post_data to string string post_str(&post_data[0], post_data.size()); @@ -2146,9 +2146,9 @@ TEST(OmahaRequestActionTest, TestChangingToLessStableChannel) { EXPECT_FALSE(params.to_more_stable_channel()); EXPECT_FALSE(params.is_powerwash_allowed()); ASSERT_FALSE(TestUpdateCheck(&prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager ¶ms, "invalid xml>", -1, @@ -2157,7 +2157,7 @@ TEST(OmahaRequestActionTest, TestChangingToLessStableChannel) { metrics::CheckResult::kParsingError, metrics::CheckReaction::kUnset, metrics::DownloadErrorCode::kUnset, - NULL, // response + nullptr, // response &post_data)); // convert post_data to string string post_str(&post_data[0], post_data.size()); @@ -2196,10 +2196,10 @@ void P2PTest(bool initial_allow_p2p_for_downloading, .Times(expect_p2p_client_lookup ? 1 : 0); ASSERT_TRUE( - TestUpdateCheck(NULL, // prefs + TestUpdateCheck(nullptr, // prefs &mock_payload_state, &mock_p2p_manager, - NULL, // connection_manager + nullptr, // connection_manager &request_params, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -2222,7 +2222,7 @@ void P2PTest(bool initial_allow_p2p_for_downloading, metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, &response, - NULL)); + nullptr)); EXPECT_TRUE(response.update_exists); EXPECT_EQ(response.disable_p2p_for_downloading, @@ -2322,9 +2322,9 @@ bool InstallDateParseHelper(const std::string &elapsed_days, OmahaResponse *response) { return TestUpdateCheck(prefs, - NULL, // payload_state - NULL, // p2p_manager - NULL, // connection_manager + nullptr, // payload_state + nullptr, // p2p_manager + nullptr, // connection_manager &kDefaultTestParams, GetUpdateResponse2(OmahaRequestParams::kAppId, "1.2.3.4", // version @@ -2347,7 +2347,7 @@ bool InstallDateParseHelper(const std::string &elapsed_days, metrics::CheckReaction::kUpdating, metrics::DownloadErrorCode::kUnset, response, - NULL); + nullptr); } TEST(OmahaRequestActionTest, ParseInstallDateFromResponse) { diff --git a/omaha_request_params.cc b/omaha_request_params.cc index 73117a4..71185f6 100644 --- a/omaha_request_params.cc +++ b/omaha_request_params.cc @@ -59,24 +59,24 @@ bool OmahaRequestParams::Init(const std::string& in_app_version, os_platform_ = OmahaRequestParams::kOsPlatform; os_version_ = OmahaRequestParams::kOsVersion; app_version_ = in_app_version.empty() ? - GetLsbValue("CHROMEOS_RELEASE_VERSION", "", NULL, stateful_override) : + GetLsbValue("CHROMEOS_RELEASE_VERSION", "", nullptr, stateful_override) : in_app_version; os_sp_ = app_version_ + "_" + GetMachineType(); os_board_ = GetLsbValue("CHROMEOS_RELEASE_BOARD", "", - NULL, + nullptr, stateful_override); string release_app_id = GetLsbValue("CHROMEOS_RELEASE_APPID", OmahaRequestParams::kAppId, - NULL, + nullptr, stateful_override); board_app_id_ = GetLsbValue("CHROMEOS_BOARD_APPID", release_app_id, - NULL, + nullptr, stateful_override); canary_app_id_ = GetLsbValue("CHROMEOS_CANARY_APPID", release_app_id, - NULL, + nullptr, stateful_override); app_lang_ = "en-US"; hwid_ = system_state_->hardware()->GetHardwareClass(); @@ -103,7 +103,7 @@ bool OmahaRequestParams::Init(const std::string& in_app_version, } if (in_update_url.empty()) - update_url_ = GetLsbValue("CHROMEOS_AUSERVER", kProductionOmahaUrl, NULL, + update_url_ = GetLsbValue("CHROMEOS_AUSERVER", kProductionOmahaUrl, nullptr, stateful_override); else update_url_ = in_update_url; @@ -165,7 +165,7 @@ void OmahaRequestParams::SetCurrentChannelFromLsbValue() { string current_channel_new_value = GetLsbValue( kUpdateChannelKey, current_channel_, - NULL, // No need to validate the read-only rootfs channel. + nullptr, // No need to validate the read-only rootfs channel. false); // stateful_override is false so we get the current channel. if (current_channel_ != current_channel_new_value) { @@ -179,7 +179,7 @@ void OmahaRequestParams::SetIsPowerwashAllowedFromLsbValue() { string is_powerwash_allowed_str = GetLsbValue( kIsPowerwashAllowedKey, "false", - NULL, // no need to validate + nullptr, // no need to validate true); // always get it from stateful, as that's the only place it'll be bool is_powerwash_allowed_new_value = (is_powerwash_allowed_str == "true"); if (is_powerwash_allowed_ != is_powerwash_allowed_new_value) { diff --git a/omaha_request_params.h b/omaha_request_params.h index 1c0ac0d..8acbc4e 100644 --- a/omaha_request_params.h +++ b/omaha_request_params.h @@ -299,7 +299,7 @@ class OmahaRequestParams { // Fetches the value for a given key from // /mnt/stateful_partition/etc/lsb-release if possible and |stateful_override| // is true. Failing that, it looks for the key in /etc/lsb-release. If - // |validator| is non-NULL, uses it to validate and ignore invalid values. + // |validator| is non-null, uses it to validate and ignore invalid values. std::string GetLsbValue(const std::string& key, const std::string& default_value, ValueValidator validator, diff --git a/omaha_request_params_unittest.cc b/omaha_request_params_unittest.cc index 432eb6c..1daed1c 100644 --- a/omaha_request_params_unittest.cc +++ b/omaha_request_params_unittest.cc @@ -25,7 +25,7 @@ class OmahaRequestParamsTest : public ::testing::Test { protected: // Return true iff the OmahaRequestParams::Init succeeded. If - // out is non-NULL, it's set w/ the generated data. + // out is non-null, it's set w/ the generated data. bool DoTest(OmahaRequestParams* out, const string& app_version, const string& omaha_url); diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc index 51eab78..46ff653 100644 --- a/omaha_response_handler_action_unittest.cc +++ b/omaha_response_handler_action_unittest.cc @@ -21,7 +21,7 @@ namespace chromeos_update_engine { class OmahaResponseHandlerActionTest : public ::testing::Test { public: // Return true iff the OmahaResponseHandlerAction succeeded. - // If out is non-NULL, it's set w/ the response from the action. + // If out is non-null, it's set w/ the response from the action. bool DoTestCommon(FakeSystemState* fake_system_state, const OmahaResponse& in, const string& boot_dev, @@ -118,7 +118,7 @@ TEST_F(OmahaResponseHandlerActionTest, SimpleTest) { string test_deadline_file; CHECK(utils::MakeTempFile( "omaha_response_handler_action_unittest-XXXXXX", - &test_deadline_file, NULL)); + &test_deadline_file, nullptr)); ScopedPathUnlinker deadline_unlinker(test_deadline_file); { OmahaResponse in; diff --git a/p2p_manager.cc b/p2p_manager.cc index 6d1a773..fcaae1a 100644 --- a/p2p_manager.cc +++ b/p2p_manager.cc @@ -135,7 +135,7 @@ class P2PManagerImpl : public P2PManager { // Utility function used by EnsureP2PRunning() and EnsureP2PNotRunning(). bool EnsureP2P(bool should_be_running); - // The device policy being used or NULL if no policy is being used. + // The device policy being used or null if no policy is being used. const policy::DevicePolicy* device_policy_; // Configuration object. @@ -170,11 +170,11 @@ P2PManagerImpl::P2PManagerImpl(Configuration *configuration, PrefsInterface *prefs, const string& file_extension, const int num_files_to_keep) - : device_policy_(NULL), + : device_policy_(nullptr), prefs_(prefs), file_extension_(file_extension), num_files_to_keep_(num_files_to_keep) { - configuration_.reset(configuration != NULL ? configuration : + configuration_.reset(configuration != nullptr ? configuration : new ConfigurationImpl()); } @@ -195,7 +195,7 @@ bool P2PManagerImpl::IsP2PEnabled() { // crosh_flag == TRUE && enterprise_policy == FALSE -> use_p2p == TRUE // crosh_flag == TRUE && enterprise_policy == TRUE -> use_p2p == TRUE - if (device_policy_ != NULL) { + if (device_policy_ != nullptr) { if (device_policy_->GetAuP2PEnabled(&p2p_enabled)) { if (p2p_enabled) { LOG(INFO) << "Enterprise Policy indicates that p2p is enabled."; @@ -204,7 +204,7 @@ bool P2PManagerImpl::IsP2PEnabled() { } } - if (prefs_ != NULL && + if (prefs_ != nullptr && prefs_->Exists(kPrefsP2PEnabled) && prefs_->GetBoolean(kPrefsP2PEnabled, &p2p_enabled) && p2p_enabled) { @@ -218,19 +218,19 @@ bool P2PManagerImpl::IsP2PEnabled() { } bool P2PManagerImpl::EnsureP2P(bool should_be_running) { - gchar *standard_error = NULL; - GError *error = NULL; + gchar *standard_error = nullptr; + GError *error = nullptr; gint exit_status = 0; vector args = configuration_->GetInitctlArgs(should_be_running); scoped_ptr argv( utils::StringVectorToGStrv(args)); - if (!g_spawn_sync(NULL, // working_directory + if (!g_spawn_sync(nullptr, // working_directory argv.get(), - NULL, // envp + nullptr, // envp static_cast(G_SPAWN_SEARCH_PATH), - NULL, NULL, // child_setup, user_data - NULL, // standard_output + nullptr, nullptr, // child_setup, user_data + nullptr, // standard_output &standard_error, &exit_status, &error)) { @@ -307,16 +307,16 @@ FilePath P2PManagerImpl::GetPath(const string& file_id, Visibility visibility) { } bool P2PManagerImpl::PerformHousekeeping() { - GDir* dir = NULL; - GError* error = NULL; - const char* name = NULL; + GDir* dir = nullptr; + GError* error = nullptr; + const char* name = nullptr; vector > matches; // Go through all files in the p2p dir and pick the ones that match // and get their ctime. base::FilePath p2p_dir = configuration_->GetP2PDir(); dir = g_dir_open(p2p_dir.value().c_str(), 0, &error); - if (dir == NULL) { + if (dir == nullptr) { LOG(ERROR) << "Error opening directory " << p2p_dir.value() << ": " << utils::GetAndFreeGError(&error); return false; @@ -327,7 +327,7 @@ bool P2PManagerImpl::PerformHousekeeping() { string ext_visible = GetExt(kVisible); string ext_non_visible = GetExt(kNonVisible); - while ((name = g_dir_read_name(dir)) != NULL) { + while ((name = g_dir_read_name(dir)) != nullptr) { if (!(g_str_has_suffix(name, ext_visible.c_str()) || g_str_has_suffix(name, ext_non_visible.c_str()))) continue; @@ -392,18 +392,18 @@ class LookupData { // the callback is always called from the GLib mainloop (this // guarantee is useful for testing). - GError *error = NULL; - if (!g_spawn_async_with_pipes(NULL, // working_directory + GError *error = nullptr; + if (!g_spawn_async_with_pipes(nullptr, // working_directory argv, - NULL, // envp + nullptr, // envp static_cast(G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD), - NULL, // child_setup + nullptr, // child_setup this, &pid_, - NULL, // standard_input + nullptr, // standard_input &stdout_fd_, - NULL, // standard_error + nullptr, // standard_error &error)) { LOG(ERROR) << "Error spawning p2p-client: " << utils::GetAndFreeGError(&error); @@ -480,12 +480,12 @@ class LookupData { GIOCondition condition, gpointer user_data) { LookupData *lookup_data = reinterpret_cast(user_data); - gchar* str = NULL; - GError* error = NULL; + gchar* str = nullptr; + GError* error = nullptr; GIOStatus status = g_io_channel_read_line(source, &str, - NULL, // len - NULL, // line_terminator + nullptr, // len + nullptr, // line_terminator &error); if (status != G_IO_STATUS_NORMAL) { // Ignore EOF since we usually get that before SIGCHLD and we @@ -497,7 +497,7 @@ class LookupData { delete lookup_data; } } else { - if (str != NULL) { + if (str != nullptr) { lookup_data->stdout_ += str; g_free(str); } @@ -660,7 +660,7 @@ bool P2PManagerImpl::FileGetVisible(const string& file_id, LOG(ERROR) << "No file for id " << file_id; return false; } - if (out_result != NULL) + if (out_result != nullptr) *out_result = path.MatchesExtension(kP2PExtension); return true; } @@ -716,7 +716,7 @@ ssize_t P2PManagerImpl::FileGetExpectedSize(const string& file_id) { return -1; } - char* endp = NULL; + char* endp = nullptr; long long int val = strtoll(ea_value, &endp, 0); // NOLINT(runtime/int) if (*endp != '\0') { LOG(ERROR) << "Error parsing the value '" << ea_value @@ -730,13 +730,13 @@ ssize_t P2PManagerImpl::FileGetExpectedSize(const string& file_id) { int P2PManagerImpl::CountSharedFiles() { GDir* dir; - GError* error = NULL; + GError* error = nullptr; const char* name; int num_files = 0; base::FilePath p2p_dir = configuration_->GetP2PDir(); dir = g_dir_open(p2p_dir.value().c_str(), 0, &error); - if (dir == NULL) { + if (dir == nullptr) { LOG(ERROR) << "Error opening directory " << p2p_dir.value() << ": " << utils::GetAndFreeGError(&error); return -1; @@ -744,7 +744,7 @@ int P2PManagerImpl::CountSharedFiles() { string ext_visible = GetExt(kVisible); string ext_non_visible = GetExt(kNonVisible); - while ((name = g_dir_read_name(dir)) != NULL) { + while ((name = g_dir_read_name(dir)) != nullptr) { if (g_str_has_suffix(name, ext_visible.c_str()) || g_str_has_suffix(name, ext_non_visible.c_str())) { num_files += 1; diff --git a/p2p_manager.h b/p2p_manager.h index 0e6e1b4..b2cb999 100644 --- a/p2p_manager.h +++ b/p2p_manager.h @@ -49,7 +49,7 @@ class P2PManager { typedef base::Callback LookupCallback; // Use the device policy specified by |device_policy|. If this is - // NULL, then no device policy is used. + // null, then no device policy is used. virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy) = 0; // Returns true if - and only if - P2P should be used on this @@ -133,7 +133,7 @@ class P2PManager { virtual ssize_t FileGetExpectedSize(const std::string& file_id) = 0; // Gets whether the file identified by |file_id| is publicly - // visible. If |out_result| is not NULL, the result is returned + // visible. If |out_result| is not null, the result is returned // there. Returns false if an error occurs. virtual bool FileGetVisible(const std::string& file_id, bool *out_result) = 0; @@ -152,7 +152,7 @@ class P2PManager { // Creates a suitable P2PManager instance and initializes the object // so it's ready for use. The |file_extension| parameter is used to // identify your application, use e.g. "cros_au". If - // |configuration| is non-NULL, the P2PManager will take ownership + // |configuration| is non-null, the P2PManager will take ownership // of the Configuration object and use it (hence, it must be // heap-allocated). // diff --git a/p2p_manager_unittest.cc b/p2p_manager_unittest.cc index eaf66a1..56ba33b 100644 --- a/p2p_manager_unittest.cc +++ b/p2p_manager_unittest.cc @@ -142,7 +142,7 @@ TEST_F(P2PManagerTest, P2PEnabledEnterpriseSettingFalse) { // Check that we keep the $N newest files with the .$EXT.p2p extension. TEST_F(P2PManagerTest, Housekeeping) { scoped_ptr manager(P2PManager::Construct(test_conf_, - NULL, "cros_au", 3)); + nullptr, "cros_au", 3)); EXPECT_EQ(manager->CountSharedFiles(), 0); // Generate files with different timestamps matching our pattern and generate @@ -242,9 +242,9 @@ static bool CheckP2PFile(const string& p2p_dir, const string& file_name, LOG(ERROR) << "Error getting xattr attribute"; return false; } - char* endp = NULL; + char* endp = nullptr; long long int val = strtoll(ea_value, &endp, 0); // NOLINT(runtime/int) - if (endp == NULL || *endp != '\0') { + if (endp == nullptr || *endp != '\0') { LOG(ERROR) << "Error parsing xattr '" << ea_value << "' as an integer"; return false; @@ -297,7 +297,7 @@ TEST_F(P2PManagerTest, ShareFile) { } scoped_ptr manager(P2PManager::Construct(test_conf_, - NULL, "cros_au", 3)); + nullptr, "cros_au", 3)); EXPECT_TRUE(manager->FileShare("foo", 10 * 1000 * 1000)); EXPECT_EQ(manager->FileGetPath("foo"), test_conf_->GetP2PDir().Append("foo.cros_au.p2p.tmp")); @@ -320,7 +320,7 @@ TEST_F(P2PManagerTest, MakeFileVisible) { } scoped_ptr manager(P2PManager::Construct(test_conf_, - NULL, "cros_au", 3)); + nullptr, "cros_au", 3)); // First, check that it's not visible. manager->FileShare("foo", 10*1000*1000); EXPECT_EQ(manager->FileGetPath("foo"), @@ -347,14 +347,14 @@ TEST_F(P2PManagerTest, ExistingFiles) { } scoped_ptr manager(P2PManager::Construct(test_conf_, - NULL, "cros_au", 3)); + nullptr, "cros_au", 3)); bool visible; // Check that errors are returned if the file does not exist EXPECT_EQ(manager->FileGetPath("foo"), base::FilePath()); EXPECT_EQ(manager->FileGetSize("foo"), -1); EXPECT_EQ(manager->FileGetExpectedSize("foo"), -1); - EXPECT_FALSE(manager->FileGetVisible("foo", NULL)); + EXPECT_FALSE(manager->FileGetVisible("foo", nullptr)); // ... then create the file ... EXPECT_TRUE(CreateP2PFile(test_conf_->GetP2PDir().value(), "foo.cros_au.p2p", 42, 43)); @@ -370,7 +370,7 @@ TEST_F(P2PManagerTest, ExistingFiles) { EXPECT_EQ(manager->FileGetPath("bar"), base::FilePath()); EXPECT_EQ(manager->FileGetSize("bar"), -1); EXPECT_EQ(manager->FileGetExpectedSize("bar"), -1); - EXPECT_FALSE(manager->FileGetVisible("bar", NULL)); + EXPECT_FALSE(manager->FileGetVisible("bar", nullptr)); // ... then create the file ... EXPECT_TRUE(CreateP2PFile(test_conf_->GetP2PDir().value(), "bar.cros_au.p2p.tmp", 44, 45)); @@ -388,7 +388,7 @@ TEST_F(P2PManagerTest, ExistingFiles) { // behaviours of initctl(8) that we rely on. TEST_F(P2PManagerTest, StartP2P) { scoped_ptr manager(P2PManager::Construct(test_conf_, - NULL, "cros_au", 3)); + nullptr, "cros_au", 3)); // Check that we can start the service test_conf_->SetInitctlStartCommandLine("true"); @@ -406,7 +406,7 @@ TEST_F(P2PManagerTest, StartP2P) { // Same comment as for StartP2P TEST_F(P2PManagerTest, StopP2P) { scoped_ptr manager(P2PManager::Construct(test_conf_, - NULL, "cros_au", 3)); + nullptr, "cros_au", 3)); // Check that we can start the service test_conf_->SetInitctlStopCommandLine("true"); @@ -432,8 +432,8 @@ static void ExpectUrl(const string& expected_url, // can return. It's not pretty but it works. TEST_F(P2PManagerTest, LookupURL) { scoped_ptr manager(P2PManager::Construct(test_conf_, - NULL, "cros_au", 3)); - GMainLoop *loop = g_main_loop_new(NULL, FALSE); + nullptr, "cros_au", 3)); + GMainLoop *loop = g_main_loop_new(nullptr, FALSE); // Emulate p2p-client returning valid URL with "fooX", 42 and "cros_au" // being propagated in the right places. diff --git a/payload_generator/delta_diff_generator.cc b/payload_generator/delta_diff_generator.cc index 1a15f3a..8236292 100644 --- a/payload_generator/delta_diff_generator.cc +++ b/payload_generator/delta_diff_generator.cc @@ -105,7 +105,7 @@ bool GatherExtents(const string& path, // For a given regular file which must exist at new_root + path, and // may exist at old_root + path, creates a new InstallOperation and // adds it to the graph. Also, populates the |blocks| array as -// necessary, if |blocks| is non-NULL. Also, writes the data +// necessary, if |blocks| is non-null. Also, writes the data // necessary to send the file down to the client into data_fd, which // has length *data_file_size. *data_file_size is updated // appropriately. If |existing_vertex| is no kInvalidIndex, use that @@ -296,7 +296,7 @@ bool ReadUnwrittenBlocks(const vector& blocks, string temp_file_path; TEST_AND_RETURN_FALSE(utils::MakeTempFile("CrAU_temp_data.XXXXXX", &temp_file_path, - NULL)); + nullptr)); FILE* file = fopen(temp_file_path.c_str(), "w"); TEST_AND_RETURN_FALSE(file); @@ -364,11 +364,11 @@ bool ReadUnwrittenBlocks(const vector& blocks, } } } - BZ2_bzWriteClose(&err, bz_file, 0, NULL, NULL); + BZ2_bzWriteClose(&err, bz_file, 0, nullptr, nullptr); TEST_AND_RETURN_FALSE(err == BZ_OK); - bz_file = NULL; + bz_file = nullptr; TEST_AND_RETURN_FALSE_ERRNO(0 == fclose(file)); - file = NULL; + file = nullptr; vector compressed_data; LOG(INFO) << "Reading compressed data off disk"; @@ -1385,7 +1385,7 @@ bool DeltaDiffGenerator::ReorderDataBlobs( for (int i = 0; i < (manifest->install_operations_size() + manifest->kernel_install_operations_size()); i++) { - DeltaArchiveManifest_InstallOperation* op = NULL; + DeltaArchiveManifest_InstallOperation* op = nullptr; if (i < manifest->install_operations_size()) { op = manifest->mutable_install_operations(i); } else { @@ -1439,7 +1439,7 @@ bool DeltaDiffGenerator::ConvertCutToFullOp(Graph* graph, TEST_AND_RETURN_FALSE(DeltaReadFile(graph, cut.old_dst, - NULL, + nullptr, kEmptyPath, new_root, (*graph)[cut.old_dst].file_name, @@ -1719,7 +1719,7 @@ bool DeltaDiffGenerator::GenerateDeltaUpdateFile( TEST_AND_RETURN_FALSE(utils::MakeTempFile( "CrAU_temp_data.ordered.XXXXXX", &ordered_blobs_path, - NULL)); + nullptr)); ScopedPathUnlinker ordered_blobs_unlinker(ordered_blobs_path); TEST_AND_RETURN_FALSE(ReorderDataBlobs(&manifest, temp_file_path, @@ -1838,7 +1838,7 @@ bool DeltaDiffGenerator::BsdiffFiles(const string& old_file, string patch_file_path; TEST_AND_RETURN_FALSE( - utils::MakeTempFile(kPatchFile, &patch_file_path, NULL)); + utils::MakeTempFile(kPatchFile, &patch_file_path, nullptr)); vector cmd; cmd.push_back(kBsdiffPath); @@ -1848,7 +1848,7 @@ bool DeltaDiffGenerator::BsdiffFiles(const string& old_file, int rc = 1; vector patch_file; - TEST_AND_RETURN_FALSE(Subprocess::SynchronousExec(cmd, &rc, NULL)); + TEST_AND_RETURN_FALSE(Subprocess::SynchronousExec(cmd, &rc, nullptr)); TEST_AND_RETURN_FALSE(rc == 0); TEST_AND_RETURN_FALSE(utils::ReadFile(patch_file_path, out)); unlink(patch_file_path.c_str()); diff --git a/payload_generator/delta_diff_generator_unittest.cc b/payload_generator/delta_diff_generator_unittest.cc index 977b34d..85d041c 100644 --- a/payload_generator/delta_diff_generator_unittest.cc +++ b/payload_generator/delta_diff_generator_unittest.cc @@ -64,9 +64,9 @@ class DeltaDiffGeneratorTest : public ::testing::Test { virtual void SetUp() { ASSERT_TRUE(utils::MakeTempFile("DeltaDiffGeneratorTest-old_path-XXXXXX", - &old_path_, NULL)); + &old_path_, nullptr)); ASSERT_TRUE(utils::MakeTempFile("DeltaDiffGeneratorTest-new_path-XXXXXX", - &new_path_, NULL)); + &new_path_, nullptr)); } virtual void TearDown() { @@ -556,8 +556,8 @@ TEST_F(DeltaDiffGeneratorTest, CutEdgesTest) { TEST_F(DeltaDiffGeneratorTest, ReorderBlobsTest) { string orig_blobs; - EXPECT_TRUE( - utils::MakeTempFile("ReorderBlobsTest.orig.XXXXXX", &orig_blobs, NULL)); + EXPECT_TRUE(utils::MakeTempFile("ReorderBlobsTest.orig.XXXXXX", &orig_blobs, + nullptr)); string orig_data = "abcd"; EXPECT_TRUE( @@ -565,7 +565,7 @@ TEST_F(DeltaDiffGeneratorTest, ReorderBlobsTest) { string new_blobs; EXPECT_TRUE( - utils::MakeTempFile("ReorderBlobsTest.new.XXXXXX", &new_blobs, NULL)); + utils::MakeTempFile("ReorderBlobsTest.new.XXXXXX", &new_blobs, nullptr)); DeltaArchiveManifest manifest; DeltaArchiveManifest_InstallOperation* op = @@ -718,7 +718,7 @@ TEST_F(DeltaDiffGeneratorTest, RunAsRootAssignTempBlocksTest) { int fd; EXPECT_TRUE(utils::MakeTempFile("AssignTempBlocksTestData.XXXXXX", - NULL, + nullptr, &fd)); ScopedFdCloser fd_closer(&fd); off_t data_file_size = 0; @@ -835,7 +835,7 @@ TEST_F(DeltaDiffGeneratorTest, RunAsRootNoSparseAsTempTest) { int fd = -1; EXPECT_TRUE(utils::MakeTempFile("NoSparseAsTempTestData.XXXXXX", - NULL, + nullptr, &fd)); ScopedFdCloser fd_closer(&fd); off_t data_file_size = 0; @@ -1096,7 +1096,7 @@ TEST_F(DeltaDiffGeneratorTest, RunAsRootAssignTempBlocksReuseTest) { int fd; EXPECT_TRUE(utils::MakeTempFile("AssignTempBlocksReuseTest.XXXXXX", - NULL, + nullptr, &fd)); ScopedFdCloser fd_closer(&fd); off_t data_file_size = 0; diff --git a/payload_generator/filesystem_iterator_unittest.cc b/payload_generator/filesystem_iterator_unittest.cc index 7436c99..047c8a4 100644 --- a/payload_generator/filesystem_iterator_unittest.cc +++ b/payload_generator/filesystem_iterator_unittest.cc @@ -52,12 +52,12 @@ TEST_F(FilesystemIteratorTest, RunAsRootSuccessTest) { // Create uniquely named main/sub images. string main_image; ASSERT_TRUE(utils::MakeTempFile("FilesystemIteratorTest.image1-XXXXXX", - &main_image, NULL)); + &main_image, nullptr)); ScopedPathUnlinker main_image_unlinker(main_image); string sub_image; ASSERT_TRUE(utils::MakeTempFile("FilesystemIteratorTest.image2-XXXXXX", - &sub_image, NULL)); + &sub_image, nullptr)); ScopedPathUnlinker sub_image_unlinker(sub_image); // Create uniquely named main/sub mount points. @@ -70,7 +70,7 @@ TEST_F(FilesystemIteratorTest, RunAsRootSuccessTest) { vector expected_paths_vector; CreateExtImageAtPath(main_image, &expected_paths_vector); - CreateExtImageAtPath(sub_image, NULL); + CreateExtImageAtPath(sub_image, nullptr); ASSERT_EQ(0, System(string("mount -o loop ") + main_image + " " + main_image_mount_point)); ASSERT_EQ(0, System(string("mount -o loop ") + sub_image + " " + diff --git a/payload_generator/full_update_generator.cc b/payload_generator/full_update_generator.cc index d4d6614..5b6a6b3 100644 --- a/payload_generator/full_update_generator.cc +++ b/payload_generator/full_update_generator.cc @@ -35,7 +35,7 @@ class ChunkProcessor { public: // Read a chunk of |size| bytes from |fd| starting at offset |offset|. ChunkProcessor(int fd, off_t offset, size_t size) - : thread_(NULL), + : thread_(nullptr), fd_(fd), offset_(offset), buffer_in_(size) {} @@ -74,8 +74,9 @@ class ChunkProcessor { bool ChunkProcessor::Start() { // g_thread_create is deprecated since glib 2.32. Use // g_thread_new instead. - thread_ = g_thread_try_new("chunk_proc", ReadAndCompressThread, this, NULL); - TEST_AND_RETURN_FALSE(thread_ != NULL); + thread_ = g_thread_try_new("chunk_proc", ReadAndCompressThread, this, + nullptr); + TEST_AND_RETURN_FALSE(thread_ != nullptr); return true; } @@ -84,14 +85,14 @@ bool ChunkProcessor::Wait() { return false; } gpointer result = g_thread_join(thread_); - thread_ = NULL; + thread_ = nullptr; TEST_AND_RETURN_FALSE(result == this); return true; } gpointer ChunkProcessor::ReadAndCompressThread(gpointer data) { - return - reinterpret_cast(data)->ReadAndCompress() ? data : NULL; + return reinterpret_cast(data)->ReadAndCompress() ? + data : nullptr; } bool ChunkProcessor::ReadAndCompress() { @@ -161,7 +162,7 @@ bool FullUpdateGenerator::Run( threads.pop_front(); TEST_AND_RETURN_FALSE(processor->Wait()); - DeltaArchiveManifest_InstallOperation* op = NULL; + DeltaArchiveManifest_InstallOperation* op = nullptr; if (partition == 0) { graph->resize(graph->size() + 1); graph->back().file_name = diff --git a/payload_generator/full_update_generator_unittest.cc b/payload_generator/full_update_generator_unittest.cc index 689c5ce..7cb2d7a 100644 --- a/payload_generator/full_update_generator_unittest.cc +++ b/payload_generator/full_update_generator_unittest.cc @@ -35,14 +35,14 @@ TEST(FullUpdateGeneratorTest, RunTest) { string new_root_path; EXPECT_TRUE(utils::MakeTempFile("NewFullUpdateTest_R.XXXXXX", &new_root_path, - NULL)); + nullptr)); ScopedPathUnlinker new_root_path_unlinker(new_root_path); EXPECT_TRUE(WriteFileVector(new_root_path, new_root)); string new_kern_path; EXPECT_TRUE(utils::MakeTempFile("NewFullUpdateTest_K.XXXXXX", &new_kern_path, - NULL)); + nullptr)); ScopedPathUnlinker new_kern_path_unlinker(new_kern_path); EXPECT_TRUE(WriteFileVector(new_kern_path, new_kern)); diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc index a2b6b3c..38c4e76 100644 --- a/payload_generator/generate_delta_main.cc +++ b/payload_generator/generate_delta_main.cc @@ -264,7 +264,7 @@ void ApplyDelta() { kern_info.hash().end()); install_plan.rootfs_hash.assign(root_info.hash().begin(), root_info.hash().end()); - DeltaPerformer performer(&prefs, NULL, &install_plan); + DeltaPerformer performer(&prefs, nullptr, &install_plan); CHECK_EQ(performer.Open(FLAGS_old_image.c_str(), 0, 0), 0); CHECK(performer.OpenKernel(FLAGS_old_kernel.c_str())); vector buf(1024 * 1024); @@ -378,7 +378,7 @@ int Main(int argc, char** argv) { FLAGS_private_key, FLAGS_chunk_size, FLAGS_rootfs_partition_size, - is_delta ? &old_image_info : NULL, + is_delta ? &old_image_info : nullptr, &new_image_info, &metadata_size)) { return 1; diff --git a/payload_generator/metadata.cc b/payload_generator/metadata.cc index 7ed1727..460aa46 100644 --- a/payload_generator/metadata.cc +++ b/payload_generator/metadata.cc @@ -359,7 +359,7 @@ bool ReadInodeMetadata(Graph* graph, bool all_blocks = ((ino == EXT2_JOURNAL_INO) || is_old_dir || is_new_dir); vector old_extents; - error = ext2fs_block_iterate2(fs_old, ino, 0, NULL, + error = ext2fs_block_iterate2(fs_old, ino, 0, nullptr, all_blocks ? ProcessInodeAllBlocks : ProcessInodeMetadataBlocks, &old_extents); @@ -370,7 +370,7 @@ bool ReadInodeMetadata(Graph* graph, } vector new_extents; - error = ext2fs_block_iterate2(fs_new, ino, 0, NULL, + error = ext2fs_block_iterate2(fs_new, ino, 0, nullptr, all_blocks ? ProcessInodeAllBlocks : ProcessInodeMetadataBlocks, &new_extents); diff --git a/payload_generator/metadata_unittest.cc b/payload_generator/metadata_unittest.cc index dcce0c3..93b0917 100644 --- a/payload_generator/metadata_unittest.cc +++ b/payload_generator/metadata_unittest.cc @@ -32,9 +32,9 @@ class MetadataTest : public ::testing::Test { TEST_F(MetadataTest, RunAsRootReadMetadataDissimilarFileSystems) { string a_img, b_img; - EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &a_img, NULL)); + EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &a_img, nullptr)); ScopedPathUnlinker a_img_unlinker(a_img); - EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &b_img, NULL)); + EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &b_img, nullptr)); ScopedPathUnlinker b_img_unlinker(b_img); CreateEmptyExtImageAtPath(a_img, 10485759, 4096); @@ -47,7 +47,7 @@ TEST_F(MetadataTest, RunAsRootReadMetadataDissimilarFileSystems) { a_img, b_img, 0, - NULL)); + nullptr)); EXPECT_EQ(graph.size(), 0); CreateEmptyExtImageAtPath(a_img, 10485759, 4096); @@ -60,17 +60,17 @@ TEST_F(MetadataTest, RunAsRootReadMetadataDissimilarFileSystems) { a_img, b_img, 0, - NULL)); + nullptr)); EXPECT_EQ(graph.size(), 0); } TEST_F(MetadataTest, RunAsRootReadMetadata) { string a_img, b_img, data_file; - EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &a_img, NULL)); + EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &a_img, nullptr)); ScopedPathUnlinker a_img_unlinker(a_img); - EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &b_img, NULL)); + EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &b_img, nullptr)); ScopedPathUnlinker b_img_unlinker(b_img); - EXPECT_TRUE(utils::MakeTempFile("data_file.XXXXXX", &data_file, NULL)); + EXPECT_TRUE(utils::MakeTempFile("data_file.XXXXXX", &data_file, nullptr)); ScopedPathUnlinker data_file_unlinker(data_file); const size_t image_size = (256 * 1024 * 1024); // Enough for 2 block groups diff --git a/payload_generator/payload_signer.cc b/payload_generator/payload_signer.cc index 4bbb155..9a9008f 100644 --- a/payload_generator/payload_signer.cc +++ b/payload_generator/payload_signer.cc @@ -128,12 +128,12 @@ bool PayloadSigner::SignHash(const vector& hash, LOG(INFO) << "Signing hash with private key: " << private_key_path; string sig_path; TEST_AND_RETURN_FALSE( - utils::MakeTempFile("signature.XXXXXX", &sig_path, NULL)); + utils::MakeTempFile("signature.XXXXXX", &sig_path, nullptr)); ScopedPathUnlinker sig_path_unlinker(sig_path); string hash_path; TEST_AND_RETURN_FALSE( - utils::MakeTempFile("hash.XXXXXX", &hash_path, NULL)); + utils::MakeTempFile("hash.XXXXXX", &hash_path, nullptr)); ScopedPathUnlinker hash_path_unlinker(hash_path); // We expect unpadded SHA256 hash coming in TEST_AND_RETURN_FALSE(hash.size() == 32); @@ -158,7 +158,8 @@ bool PayloadSigner::SignHash(const vector& hash, cmd[0] = utils::GetPathOnBoard("openssl"); int return_code = 0; - TEST_AND_RETURN_FALSE(Subprocess::SynchronousExec(cmd, &return_code, NULL)); + TEST_AND_RETURN_FALSE(Subprocess::SynchronousExec(cmd, &return_code, + nullptr)); TEST_AND_RETURN_FALSE(return_code == 0); vector signature; @@ -193,7 +194,7 @@ bool PayloadSigner::SignatureBlobLength(const vector& private_key_paths, string x_path; TEST_AND_RETURN_FALSE( - utils::MakeTempFile("signed_data.XXXXXX", &x_path, NULL)); + utils::MakeTempFile("signed_data.XXXXXX", &x_path, nullptr)); ScopedPathUnlinker x_path_unlinker(x_path); TEST_AND_RETURN_FALSE(utils::WriteFile(x_path.c_str(), "x", 1)); diff --git a/payload_generator/payload_signer_unittest.cc b/payload_generator/payload_signer_unittest.cc index 00df88c..c2cd209 100644 --- a/payload_generator/payload_signer_unittest.cc +++ b/payload_generator/payload_signer_unittest.cc @@ -85,7 +85,7 @@ namespace { void SignSampleData(vector* out_signature_blob) { string data_path; ASSERT_TRUE( - utils::MakeTempFile("data.XXXXXX", &data_path, NULL)); + utils::MakeTempFile("data.XXXXXX", &data_path, nullptr)); ScopedPathUnlinker data_path_unlinker(data_path); ASSERT_TRUE(utils::WriteFile(data_path.c_str(), kDataToSign, diff --git a/payload_state.cc b/payload_state.cc index 1dd2ee6..b58f9a8 100644 --- a/payload_state.cc +++ b/payload_state.cc @@ -39,7 +39,7 @@ static const int kMaxBackoffDays = 16; static const uint32_t kMaxBackoffFuzzMinutes = 12 * 60; PayloadState::PayloadState() - : prefs_(NULL), + : prefs_(nullptr), using_p2p_for_downloading_(false), payload_attempt_number_(0), full_payload_attempt_number_(0), diff --git a/payload_verifier.cc b/payload_verifier.cc index c4bf912..91cb42a 100644 --- a/payload_verifier.cc +++ b/payload_verifier.cc @@ -87,7 +87,7 @@ bool PayloadVerifier::LoadPayload(const string& payload_path, LOG(INFO) << "Payload size: " << payload.size(); ErrorCode error = ErrorCode::kSuccess; InstallPlan install_plan; - DeltaPerformer delta_performer(NULL, NULL, &install_plan); + DeltaPerformer delta_performer(nullptr, nullptr, &install_plan); TEST_AND_RETURN_FALSE( delta_performer.ParsePayloadMetadata(payload, &error) == DeltaPerformer::kMetadataParseSuccess); @@ -154,9 +154,9 @@ bool PayloadVerifier::GetRawHashFromSignature( } char dummy_password[] = { ' ', 0 }; // Ensure no password is read from stdin. - RSA* rsa = PEM_read_RSA_PUBKEY(fpubkey, NULL, NULL, dummy_password); + RSA* rsa = PEM_read_RSA_PUBKEY(fpubkey, nullptr, nullptr, dummy_password); fclose(fpubkey); - TEST_AND_RETURN_FALSE(rsa != NULL); + TEST_AND_RETURN_FALSE(rsa != nullptr); unsigned int keysize = RSA_size(rsa); if (sig_data.size() > 2 * keysize) { LOG(ERROR) << "Signature size is too big for public key size."; diff --git a/postinstall_runner_action.cc b/postinstall_runner_action.cc index 562ba16..81e546e 100644 --- a/postinstall_runner_action.cc +++ b/postinstall_runner_action.cc @@ -43,7 +43,7 @@ void PostinstallRunnerAction::PerformAction() { temp_rootfs_dir_.c_str(), "ext2", mountflags, - NULL); + nullptr); // TODO(sosa): Remove once crbug.com/208022 is resolved. if (rc < 0) { LOG(INFO) << "Failed to mount install part " @@ -52,7 +52,7 @@ void PostinstallRunnerAction::PerformAction() { temp_rootfs_dir_.c_str(), "ext3", mountflags, - NULL); + nullptr); } if (rc < 0) { LOG(ERROR) << "Unable to mount destination device " << install_device diff --git a/postinstall_runner_action.h b/postinstall_runner_action.h index ee7c0b8..e7ac1c5 100644 --- a/postinstall_runner_action.h +++ b/postinstall_runner_action.h @@ -19,7 +19,7 @@ class PostinstallRunnerAction : public InstallPlanAction { public: PostinstallRunnerAction() : powerwash_marker_created_(false), - powerwash_marker_file_(NULL) {} + powerwash_marker_file_(nullptr) {} void PerformAction(); @@ -44,8 +44,8 @@ class PostinstallRunnerAction : public InstallPlanAction { // False otherwise. Used for cleaning up if post-install fails. bool powerwash_marker_created_; - // Non-NULL value will cause post-install to override the default marker file - // name; used for testing. + // Non-null value will cause post-install to override the default marker + // file name; used for testing. const char* powerwash_marker_file_; // Special ctor + friend declaration for testing purposes. diff --git a/postinstall_runner_action_unittest.cc b/postinstall_runner_action_unittest.cc index acceb2b..d5e795e 100644 --- a/postinstall_runner_action_unittest.cc +++ b/postinstall_runner_action_unittest.cc @@ -46,7 +46,7 @@ class PostinstallRunnerActionTest : public ::testing::Test { class PostinstActionProcessorDelegate : public ActionProcessorDelegate { public: PostinstActionProcessorDelegate() - : loop_(NULL), + : loop_(nullptr), code_(ErrorCode::kError), code_set_(false) {} void ProcessingDone(const ActionProcessor* processor, @@ -218,7 +218,7 @@ void PostinstallRunnerActionTest::DoTest( ASSERT_LT(rc, 0); if (do_losetup) { - loop_releaser.reset(NULL); + loop_releaser.reset(nullptr); } // Remove unique stateful directory. diff --git a/real_system_state.cc b/real_system_state.cc index 44ff5fb..f093aad 100644 --- a/real_system_state.cc +++ b/real_system_state.cc @@ -41,7 +41,7 @@ bool RealSystemState::Initialize() { system_rebooted_ = true; } - p2p_manager_.reset(P2PManager::Construct(NULL, &prefs_, "cros_au", + p2p_manager_.reset(P2PManager::Construct(nullptr, &prefs_, "cros_au", kMaxP2PFilesToKeep)); // Initialize the Update Manager using the default state factory. diff --git a/subprocess.cc b/subprocess.cc index aab71b5..e2ab793 100644 --- a/subprocess.cc +++ b/subprocess.cc @@ -65,7 +65,7 @@ gboolean Subprocess::GStdoutWatchCallback(GIOChannel* source, buf, arraysize(buf), &bytes_read, - NULL) == G_IO_STATUS_NORMAL && + nullptr) == G_IO_STATUS_NORMAL && bytes_read > 0) { stdout->append(buf, bytes_read); } @@ -76,7 +76,7 @@ namespace { void FreeArgv(char** argv) { for (int i = 0; argv[i]; i++) { free(argv[i]); - argv[i] = NULL; + argv[i] = nullptr; } } @@ -86,7 +86,7 @@ void FreeArgvInError(char** argv) { } // Note: Caller responsible for free()ing the returned value! -// Will return NULL on failure and free any allocated memory. +// Will return null on failure and free any allocated memory. char** ArgPointer() { const char* keys[] = {"LD_LIBRARY_PATH", "PATH"}; char** ret = new char*[arraysize(keys) + 1]; @@ -98,12 +98,12 @@ char** ArgPointer() { if (!ret[pointer]) { FreeArgv(ret); delete [] ret; - return NULL; + return nullptr; } ++pointer; } } - ret[pointer] = NULL; + ret[pointer] = nullptr; return ret; } @@ -131,15 +131,15 @@ uint32_t Subprocess::Exec(const vector& cmd, for (unsigned int i = 0; i < cmd.size(); i++) { argv[i] = strdup(cmd[i].c_str()); if (!argv[i]) { - FreeArgvInError(argv.get()); // NULL in argv[i] terminates argv. + FreeArgvInError(argv.get()); // null in argv[i] terminates argv. return 0; } } - argv[cmd.size()] = NULL; + argv[cmd.size()] = nullptr; char** argp = ArgPointer(); if (!argp) { - FreeArgvInError(argv.get()); // NULL in argv[i] terminates argv. + FreeArgvInError(argv.get()); // null in argv[i] terminates argv. return 0; } ScopedFreeArgPointer argp_free(argp); @@ -150,16 +150,16 @@ uint32_t Subprocess::Exec(const vector& cmd, gint stdout_fd = -1; GError* error = nullptr; bool success = g_spawn_async_with_pipes( - NULL, // working directory + nullptr, // working directory argv.get(), argp, G_SPAWN_DO_NOT_REAP_CHILD, // flags GRedirectStderrToStdout, // child setup function - NULL, // child setup data pointer + nullptr, // child setup data pointer &child_pid, - NULL, + nullptr, &stdout_fd, - NULL, + nullptr, &error); FreeArgv(argv.get()); if (!success) { @@ -172,9 +172,9 @@ uint32_t Subprocess::Exec(const vector& cmd, // Capture the subprocess output. record->gioout = g_io_channel_unix_new(stdout_fd); - g_io_channel_set_encoding(record->gioout, NULL, NULL); + g_io_channel_set_encoding(record->gioout, nullptr, nullptr); LOG_IF(WARNING, - g_io_channel_set_flags(record->gioout, G_IO_FLAG_NONBLOCK, NULL) != + g_io_channel_set_flags(record->gioout, G_IO_FLAG_NONBLOCK, nullptr) != G_IO_STATUS_NORMAL) << "Unable to set non-blocking I/O mode."; record->gioout_tag = g_io_add_watch( record->gioout, @@ -185,7 +185,7 @@ uint32_t Subprocess::Exec(const vector& cmd, } void Subprocess::CancelExec(uint32_t tag) { - subprocess_records_[tag]->callback = NULL; + subprocess_records_[tag]->callback = nullptr; } bool Subprocess::SynchronousExecFlags(const vector& cmd, @@ -195,35 +195,35 @@ bool Subprocess::SynchronousExecFlags(const vector& cmd, if (stdout) { *stdout = ""; } - GError* err = NULL; + GError* err = nullptr; scoped_ptr argv(new char*[cmd.size() + 1]); for (unsigned int i = 0; i < cmd.size(); i++) { argv[i] = strdup(cmd[i].c_str()); if (!argv[i]) { - FreeArgvInError(argv.get()); // NULL in argv[i] terminates argv. + FreeArgvInError(argv.get()); // null in argv[i] terminates argv. return false; } } - argv[cmd.size()] = NULL; + argv[cmd.size()] = nullptr; char** argp = ArgPointer(); if (!argp) { - FreeArgvInError(argv.get()); // NULL in argv[i] terminates argv. + FreeArgvInError(argv.get()); // null in argv[i] terminates argv. return false; } ScopedFreeArgPointer argp_free(argp); char* child_stdout; bool success = g_spawn_sync( - NULL, // working directory + nullptr, // working directory argv.get(), argp, static_cast(G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_SEARCH_PATH | flags), // flags GRedirectStderrToStdout, // child setup function - NULL, // data for child setup function + nullptr, // data for child setup function &child_stdout, - NULL, + nullptr, return_code, &err); FreeArgv(argv.get()); @@ -258,6 +258,6 @@ bool Subprocess::SubprocessInFlight() { return false; } -Subprocess* Subprocess::subprocess_singleton_ = NULL; +Subprocess* Subprocess::subprocess_singleton_ = nullptr; } // namespace chromeos_update_engine diff --git a/subprocess.h b/subprocess.h index 4311595..4279321 100644 --- a/subprocess.h +++ b/subprocess.h @@ -64,9 +64,9 @@ class Subprocess { struct SubprocessRecord { SubprocessRecord() : tag(0), - callback(NULL), - callback_data(NULL), - gioout(NULL), + callback(nullptr), + callback_data(nullptr), + gioout(nullptr), gioout_tag(0) {} uint32_t tag; ExecCallback callback; diff --git a/subprocess_unittest.cc b/subprocess_unittest.cc index 7c25075..9ef3e0b 100644 --- a/subprocess_unittest.cc +++ b/subprocess_unittest.cc @@ -101,7 +101,7 @@ TEST(SubprocessTest, SynchronousEchoNoOutputTest) { cmd.push_back("-c"); cmd.push_back("echo test"); int rc = -1; - ASSERT_TRUE(Subprocess::SynchronousExec(cmd, &rc, NULL)); + ASSERT_TRUE(Subprocess::SynchronousExec(cmd, &rc, nullptr)); EXPECT_EQ(0, rc); } @@ -136,7 +136,7 @@ gboolean StartAndCancelInRunLoop(gpointer data) { vector cmd; cmd.push_back("./test_http_server"); cmd.push_back(temp_file_name); - uint32_t tag = Subprocess::Get().Exec(cmd, CallbackBad, NULL); + uint32_t tag = Subprocess::Get().Exec(cmd, CallbackBad, nullptr); EXPECT_NE(0, tag); cancel_test_data->spawned = true; printf("test http server spawned\n"); diff --git a/test_http_server.cc b/test_http_server.cc index f5f9202..2687d99 100644 --- a/test_http_server.cc +++ b/test_http_server.cc @@ -604,7 +604,7 @@ int main(int argc, char** argv) { while (1) { LOG(INFO) << "pid(" << getpid() << "): waiting to accept new connection"; - int client_fd = accept(listen_fd, NULL, NULL); + int client_fd = accept(listen_fd, nullptr, nullptr); LOG(INFO) << "got past accept"; if (client_fd < 0) LOG(FATAL) << "ERROR on accept"; diff --git a/test_utils.cc b/test_utils.cc index b452ca3..70eb35c 100644 --- a/test_utils.cc +++ b/test_utils.cc @@ -319,7 +319,7 @@ static gboolean RunGMainLoopOnTimeout(gpointer user_data) { } void RunGMainLoopUntil(int timeout_msec, base::Callback terminate) { - GMainLoop* loop = g_main_loop_new(NULL, FALSE); + GMainLoop* loop = g_main_loop_new(nullptr, FALSE); GMainContext* context = g_main_context_default(); bool timeout = false; diff --git a/test_utils.h b/test_utils.h index e81eabd..45f409c 100644 --- a/test_utils.h +++ b/test_utils.h @@ -153,7 +153,7 @@ class ScopedLoopbackDeviceBinder { args.push_back("-d"); args.push_back(dev_); int return_code = 0; - EXPECT_TRUE(Subprocess::SynchronousExec(args, &return_code, NULL)); + EXPECT_TRUE(Subprocess::SynchronousExec(args, &return_code, nullptr)); if (return_code == 0) { return; } @@ -180,7 +180,7 @@ class ScopedTempFile { ScopedTempFile() { EXPECT_TRUE(utils::MakeTempFile("/tmp/update_engine_test_temp_file.XXXXXX", &path_, - NULL)); + nullptr)); unlinker_.reset(new ScopedPathUnlinker(path_)); } const std::string& GetPath() { return path_; } diff --git a/update_attempter.cc b/update_attempter.cc index d0ef575..c6f1588 100644 --- a/update_attempter.cc +++ b/update_attempter.cc @@ -188,7 +188,7 @@ bool UpdateAttempter::CheckAndReportDailyMetrics() { void UpdateAttempter::ReportOSAge() { struct stat sb; - if (system_state_ == NULL) + if (system_state_ == nullptr) return; if (stat("/etc/lsb-release", &sb) != 0) { @@ -278,7 +278,7 @@ void UpdateAttempter::RefreshDevicePolicy() { policy_provider_.reset(new policy::PolicyProvider()); policy_provider_->Reload(); - const policy::DevicePolicy* device_policy = NULL; + const policy::DevicePolicy* device_policy = nullptr; if (policy_provider_->device_policy_is_loaded()) device_policy = &policy_provider_->GetDevicePolicy(); @@ -302,7 +302,7 @@ void UpdateAttempter::CalculateP2PParams(bool interactive) { // update_engine or p2p codebases so he can actually test his // code.). - if (system_state_ != NULL) { + if (system_state_ != nullptr) { if (!system_state_->p2p_manager()->IsP2PEnabled()) { LOG(INFO) << "p2p is not enabled - disallowing p2p for both" << " downloading and sharing."; @@ -587,7 +587,7 @@ void UpdateAttempter::BuildUpdateActions(bool interactive) { update_check_fetcher->set_check_certificate(CertificateChecker::kUpdate); shared_ptr update_check_action( new OmahaRequestAction(system_state_, - NULL, + nullptr, update_check_fetcher, // passes ownership false)); shared_ptr response_handler_action( @@ -846,7 +846,7 @@ void UpdateAttempter::WriteUpdateCompletedMarker() { } bool UpdateAttempter::RequestPowerManagerReboot() { - GError* error = NULL; + GError* error = nullptr; DBusGConnection* bus = dbus_iface_->BusGet(DBUS_BUS_SYSTEM, &error); if (!bus) { LOG(ERROR) << "Failed to get system bus: " @@ -884,7 +884,7 @@ bool UpdateAttempter::RebootDirectly() { command.push_back("now"); LOG(INFO) << "Running \"" << JoinString(command, ' ') << "\""; int rc = 0; - Subprocess::SynchronousExec(command, &rc, NULL); + Subprocess::SynchronousExec(command, &rc, nullptr); return rc == 0; } @@ -935,8 +935,8 @@ void UpdateAttempter::ProcessingDone(const ActionProcessor* processor, SetStatusAndNotify(UPDATE_STATUS_UPDATED_NEED_REBOOT); LOG(INFO) << "Update successfully applied, waiting to reboot."; - // This pointer is NULL during rollback operations, and the stats - // don't make much sense then anway. + // This pointer is null during rollback operations, and the stats + // don't make much sense then anyway. if (response_handler_action_) { const InstallPlan& install_plan = response_handler_action_->install_plan(); @@ -977,7 +977,7 @@ void UpdateAttempter::ProcessingStopped(const ActionProcessor* processor) { download_progress_ = 0.0; SetStatusAndNotify(UPDATE_STATUS_IDLE); actions_.clear(); - error_event_.reset(NULL); + error_event_.reset(nullptr); } // Called whenever an action has finished processing, either successfully @@ -1039,7 +1039,7 @@ void UpdateAttempter::ActionCompleted(ActionProcessor* processor, // cases when the server and the client are unable to initiate the download. CHECK(action == response_handler_action_.get()); const InstallPlan& plan = response_handler_action_->install_plan(); - last_checked_time_ = time(NULL); + last_checked_time_ = time(nullptr); new_version_ = plan.version; new_payload_size_ = plan.payload_size; SetupDownload(); @@ -1276,7 +1276,7 @@ void UpdateAttempter::CreatePendingErrorEvent(AbstractAction* action, } bool UpdateAttempter::ScheduleErrorEventAction() { - if (error_event_.get() == NULL) + if (error_event_.get() == nullptr) return false; LOG(ERROR) << "Update failed."; @@ -1320,15 +1320,15 @@ void UpdateAttempter::SetupCpuSharesManagement() { g_source_set_callback(manage_shares_source_, StaticManageCpuSharesCallback, this, - NULL); - g_source_attach(manage_shares_source_, NULL); + nullptr); + g_source_attach(manage_shares_source_, nullptr); SetCpuShares(utils::kCpuSharesLow); } void UpdateAttempter::CleanupCpuSharesManagement() { if (manage_shares_source_) { g_source_destroy(manage_shares_source_); - manage_shares_source_ = NULL; + manage_shares_source_ = nullptr; } SetCpuShares(utils::kCpuSharesNormal); } @@ -1350,7 +1350,7 @@ void UpdateAttempter::ScheduleProcessingStart() { bool UpdateAttempter::ManageCpuSharesCallback() { SetCpuShares(utils::kCpuSharesNormal); - manage_shares_source_ = NULL; + manage_shares_source_ = nullptr; return false; // Destroy the timeout source. } @@ -1402,12 +1402,12 @@ void UpdateAttempter::PingOmaha() { if (!processor_->IsRunning()) { shared_ptr ping_action( new OmahaRequestAction(system_state_, - NULL, + nullptr, new LibcurlHttpFetcher(GetProxyResolver(), system_state_), true)); actions_.push_back(shared_ptr(ping_action)); - processor_->set_delegate(NULL); + processor_->set_delegate(nullptr); processor_->EnqueueAction(ping_action.get()); // Call StartProcessing() synchronously here to avoid any race conditions // caused by multiple outstanding ping Omaha requests. If we call @@ -1481,7 +1481,7 @@ bool UpdateAttempter::DecrementUpdateCheckCount() { void UpdateAttempter::UpdateEngineStarted() { // If we just booted into a new update, keep the previous OS version // in case we rebooted because of a crash of the old version, so we - // can do a proper crash report with correcy information. + // can do a proper crash report with correct information. // This must be done before calling // system_state_->payload_state()->UpdateEngineStarted() since it will // delete SystemUpdated marker file. @@ -1498,7 +1498,7 @@ void UpdateAttempter::UpdateEngineStarted() { } bool UpdateAttempter::StartP2PAtStartup() { - if (system_state_ == NULL || + if (system_state_ == nullptr || !system_state_->p2p_manager()->IsP2PEnabled()) { LOG(INFO) << "Not starting p2p at startup since it's not enabled."; return false; @@ -1514,7 +1514,7 @@ bool UpdateAttempter::StartP2PAtStartup() { } bool UpdateAttempter::StartP2PAndPerformHousekeeping() { - if (system_state_ == NULL) + if (system_state_ == nullptr) return false; if (!system_state_->p2p_manager()->IsP2PEnabled()) { diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc index c9ff687..765d71d 100644 --- a/update_attempter_unittest.cc +++ b/update_attempter_unittest.cc @@ -64,7 +64,7 @@ class UpdateAttempterTest : public ::testing::Test { UpdateAttempterTest() : attempter_(&fake_system_state_, &dbus_), mock_connection_manager(&fake_system_state_), - loop_(NULL) { + loop_(nullptr) { // Override system state members. fake_system_state_.set_connection_manager(&mock_connection_manager); fake_system_state_.set_update_attempter(&attempter_); @@ -82,12 +82,12 @@ class UpdateAttempterTest : public ::testing::Test { virtual void SetUp() { CHECK(utils::MakeTempDirectory("UpdateAttempterTest-XXXXXX", &test_dir_)); - EXPECT_EQ(NULL, attempter_.dbus_service_); - EXPECT_TRUE(attempter_.system_state_ != NULL); - EXPECT_EQ(NULL, attempter_.update_check_scheduler_); + EXPECT_EQ(nullptr, attempter_.dbus_service_); + EXPECT_NE(nullptr, attempter_.system_state_); + EXPECT_EQ(nullptr, attempter_.update_check_scheduler_); EXPECT_EQ(0, attempter_.http_response_code_); EXPECT_EQ(utils::kCpuSharesNormal, attempter_.shares_); - EXPECT_EQ(NULL, attempter_.manage_shares_source_); + EXPECT_EQ(nullptr, attempter_.manage_shares_source_); EXPECT_FALSE(attempter_.download_active_); EXPECT_EQ(UPDATE_STATUS_IDLE, attempter_.status_); EXPECT_EQ(0.0, attempter_.download_progress_); @@ -170,14 +170,14 @@ class UpdateAttempterTest : public ::testing::Test { }; TEST_F(UpdateAttempterTest, ActionCompletedDownloadTest) { - scoped_ptr fetcher(new MockHttpFetcher("", 0, NULL)); + scoped_ptr fetcher(new MockHttpFetcher("", 0, nullptr)); fetcher->FailTransfer(503); // Sets the HTTP response code. - DownloadAction action(prefs_, NULL, fetcher.release()); + DownloadAction action(prefs_, nullptr, fetcher.release()); EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)).Times(0); - attempter_.ActionCompleted(NULL, &action, ErrorCode::kSuccess); + attempter_.ActionCompleted(nullptr, &action, ErrorCode::kSuccess); EXPECT_EQ(503, attempter_.http_response_code()); EXPECT_EQ(UPDATE_STATUS_FINALIZING, attempter_.status()); - ASSERT_TRUE(attempter_.error_event_.get() == NULL); + ASSERT_EQ(nullptr, attempter_.error_event_.get()); } TEST_F(UpdateAttempterTest, ActionCompletedErrorTest) { @@ -186,14 +186,14 @@ TEST_F(UpdateAttempterTest, ActionCompletedErrorTest) { attempter_.status_ = UPDATE_STATUS_DOWNLOADING; EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)) .WillOnce(Return(false)); - attempter_.ActionCompleted(NULL, &action, ErrorCode::kError); - ASSERT_TRUE(attempter_.error_event_.get() != NULL); + attempter_.ActionCompleted(nullptr, &action, ErrorCode::kError); + ASSERT_NE(nullptr, attempter_.error_event_.get()); } TEST_F(UpdateAttempterTest, ActionCompletedOmahaRequestTest) { - scoped_ptr fetcher(new MockHttpFetcher("", 0, NULL)); + scoped_ptr fetcher(new MockHttpFetcher("", 0, nullptr)); fetcher->FailTransfer(500); // Sets the HTTP response code. - OmahaRequestAction action(&fake_system_state_, NULL, + OmahaRequestAction action(&fake_system_state_, nullptr, fetcher.release(), false); ObjectCollectorAction collector_action; BondActions(&action, &collector_action); @@ -203,18 +203,18 @@ TEST_F(UpdateAttempterTest, ActionCompletedOmahaRequestTest) { UpdateCheckScheduler scheduler(&attempter_, &fake_system_state_); attempter_.set_update_check_scheduler(&scheduler); EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)).Times(0); - attempter_.ActionCompleted(NULL, &action, ErrorCode::kSuccess); + attempter_.ActionCompleted(nullptr, &action, ErrorCode::kSuccess); EXPECT_EQ(500, attempter_.http_response_code()); EXPECT_EQ(UPDATE_STATUS_IDLE, attempter_.status()); EXPECT_EQ(234, scheduler.poll_interval()); - ASSERT_TRUE(attempter_.error_event_.get() == NULL); + ASSERT_TRUE(attempter_.error_event_.get() == nullptr); } TEST_F(UpdateAttempterTest, RunAsRootConstructWithUpdatedMarkerTest) { string test_update_completed_marker; CHECK(utils::MakeTempFile( "update_attempter_unittest-update_completed_marker-XXXXXX", - &test_update_completed_marker, NULL)); + &test_update_completed_marker, nullptr)); ScopedPathUnlinker completed_marker_unlinker(test_update_completed_marker); const base::FilePath marker(test_update_completed_marker); EXPECT_EQ(0, base::WriteFile(marker, "", 0)); @@ -227,11 +227,11 @@ TEST_F(UpdateAttempterTest, GetErrorCodeForActionTest) { extern ErrorCode GetErrorCodeForAction(AbstractAction* action, ErrorCode code); EXPECT_EQ(ErrorCode::kSuccess, - GetErrorCodeForAction(NULL, ErrorCode::kSuccess)); + GetErrorCodeForAction(nullptr, ErrorCode::kSuccess)); FakeSystemState fake_system_state; - OmahaRequestAction omaha_request_action(&fake_system_state, NULL, - NULL, false); + OmahaRequestAction omaha_request_action(&fake_system_state, nullptr, + nullptr, false); EXPECT_EQ(ErrorCode::kOmahaRequestError, GetErrorCodeForAction(&omaha_request_action, ErrorCode::kError)); OmahaResponseHandlerAction omaha_response_handler_action(&fake_system_state_); @@ -465,7 +465,7 @@ void UpdateAttempterTest::UpdateTestVerify() { attempter_.actions_[1].get()); DownloadAction* download_action = dynamic_cast(attempter_.actions_[5].get()); - ASSERT_TRUE(download_action != NULL); + ASSERT_NE(nullptr, download_action); EXPECT_EQ(&attempter_, download_action->delegate()); EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status()); g_main_loop_quit(loop_); @@ -549,7 +549,7 @@ TEST_F(UpdateAttempterTest, UpdateTest) { g_idle_add(&StaticUpdateTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } TEST_F(UpdateAttempterTest, RollbackTest) { @@ -557,7 +557,7 @@ TEST_F(UpdateAttempterTest, RollbackTest) { g_idle_add(&StaticRollbackTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } TEST_F(UpdateAttempterTest, InvalidSlotRollbackTest) { @@ -565,7 +565,7 @@ TEST_F(UpdateAttempterTest, InvalidSlotRollbackTest) { g_idle_add(&StaticInvalidSlotRollbackTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } TEST_F(UpdateAttempterTest, EnterpriseRollbackTest) { @@ -573,7 +573,7 @@ TEST_F(UpdateAttempterTest, EnterpriseRollbackTest) { g_idle_add(&StaticEnterpriseRollbackTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } void UpdateAttempterTest::PingOmahaTestStart() { @@ -595,7 +595,7 @@ TEST_F(UpdateAttempterTest, PingOmahaTest) { g_idle_add(&StaticPingOmahaTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; EXPECT_EQ(UPDATE_STATUS_UPDATED_NEED_REBOOT, attempter_.status()); EXPECT_EQ(true, scheduler.scheduled_); } @@ -604,7 +604,7 @@ TEST_F(UpdateAttempterTest, CreatePendingErrorEventTest) { ActionMock action; const ErrorCode kCode = ErrorCode::kDownloadTransferError; attempter_.CreatePendingErrorEvent(&action, kCode); - ASSERT_TRUE(attempter_.error_event_.get() != NULL); + ASSERT_NE(nullptr, attempter_.error_event_.get()); EXPECT_EQ(OmahaEvent::kTypeUpdateComplete, attempter_.error_event_->type); EXPECT_EQ(OmahaEvent::kResultError, attempter_.error_event_->result); EXPECT_EQ( @@ -621,7 +621,7 @@ TEST_F(UpdateAttempterTest, CreatePendingErrorEventResumedTest) { ActionMock action; const ErrorCode kCode = ErrorCode::kInstallDeviceOpenError; attempter_.CreatePendingErrorEvent(&action, kCode); - ASSERT_TRUE(attempter_.error_event_.get() != NULL); + ASSERT_NE(nullptr, attempter_.error_event_.get()); EXPECT_EQ(OmahaEvent::kTypeUpdateComplete, attempter_.error_event_->type); EXPECT_EQ(OmahaEvent::kResultError, attempter_.error_event_->result); EXPECT_EQ( @@ -637,7 +637,7 @@ TEST_F(UpdateAttempterTest, ReadChannelFromPolicy) { g_idle_add(&StaticReadChannelFromPolicyTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } void UpdateAttempterTest::ReadChannelFromPolicyTestStart() { @@ -672,7 +672,7 @@ TEST_F(UpdateAttempterTest, ReadUpdateDisabledFromPolicy) { g_idle_add(&StaticReadUpdateDisabledFromPolicyTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } void UpdateAttempterTest::ReadUpdateDisabledFromPolicyTestStart() { @@ -726,7 +726,7 @@ TEST_F(UpdateAttempterTest, P2PNotEnabled) { g_idle_add(&StaticP2PNotEnabled, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } gboolean UpdateAttempterTest::StaticP2PNotEnabled(gpointer data) { UpdateAttempterTest* ua_test = reinterpret_cast(data); @@ -751,7 +751,7 @@ TEST_F(UpdateAttempterTest, P2PEnabledStartingFails) { g_idle_add(&StaticP2PEnabledStartingFails, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } gboolean UpdateAttempterTest::StaticP2PEnabledStartingFails( gpointer data) { @@ -779,7 +779,7 @@ TEST_F(UpdateAttempterTest, P2PEnabledHousekeepingFails) { g_idle_add(&StaticP2PEnabledHousekeepingFails, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } gboolean UpdateAttempterTest::StaticP2PEnabledHousekeepingFails( gpointer data) { @@ -807,7 +807,7 @@ TEST_F(UpdateAttempterTest, P2PEnabled) { g_idle_add(&StaticP2PEnabled, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } gboolean UpdateAttempterTest::StaticP2PEnabled(gpointer data) { UpdateAttempterTest* ua_test = reinterpret_cast(data); @@ -834,7 +834,7 @@ TEST_F(UpdateAttempterTest, P2PEnabledInteractive) { g_idle_add(&StaticP2PEnabledInteractive, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } gboolean UpdateAttempterTest::StaticP2PEnabledInteractive(gpointer data) { UpdateAttempterTest* ua_test = reinterpret_cast(data); @@ -862,7 +862,7 @@ TEST_F(UpdateAttempterTest, ReadTargetVersionPrefixFromPolicy) { g_idle_add(&StaticReadTargetVersionPrefixFromPolicyTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } void UpdateAttempterTest::ReadTargetVersionPrefixFromPolicyTestStart() { @@ -895,7 +895,7 @@ TEST_F(UpdateAttempterTest, ReadScatterFactorFromPolicy) { g_idle_add(&StaticReadScatterFactorFromPolicyTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } // Tests that the scatter_factor_in_seconds value is properly fetched @@ -925,7 +925,7 @@ TEST_F(UpdateAttempterTest, DecrementUpdateCheckCountTest) { g_idle_add(&StaticDecrementUpdateCheckCountTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } void UpdateAttempterTest::DecrementUpdateCheckCountTestStart() { @@ -988,7 +988,7 @@ TEST_F(UpdateAttempterTest, NoScatteringDoneDuringManualUpdateTestStart) { g_idle_add(&StaticNoScatteringDoneDuringManualUpdateTestStart, this); g_main_loop_run(loop_); g_main_loop_unref(loop_); - loop_ = NULL; + loop_ = nullptr; } void UpdateAttempterTest::NoScatteringDoneDuringManualUpdateTestStart() { diff --git a/update_check_scheduler.cc b/update_check_scheduler.cc index 8eff465..5358416 100644 --- a/update_check_scheduler.cc +++ b/update_check_scheduler.cc @@ -32,7 +32,7 @@ UpdateCheckScheduler::~UpdateCheckScheduler() {} void UpdateCheckScheduler::Run() { enabled_ = false; - update_attempter_->set_update_check_scheduler(NULL); + update_attempter_->set_update_check_scheduler(nullptr); if (!system_state_->hardware()->IsOfficialBuild()) { LOG(WARNING) << "Non-official build: periodic update checks disabled."; diff --git a/update_check_scheduler_unittest.cc b/update_check_scheduler_unittest.cc index cd79a23..dda3b40 100644 --- a/update_check_scheduler_unittest.cc +++ b/update_check_scheduler_unittest.cc @@ -53,7 +53,7 @@ class UpdateCheckSchedulerTest : public ::testing::Test { protected: virtual void SetUp() { test_ = this; - loop_ = NULL; + loop_ = nullptr; EXPECT_EQ(&attempter_, scheduler_.update_attempter_); EXPECT_FALSE(scheduler_.enabled_); EXPECT_FALSE(scheduler_.scheduled_); @@ -65,8 +65,8 @@ class UpdateCheckSchedulerTest : public ::testing::Test { } virtual void TearDown() { - test_ = NULL; - loop_ = NULL; + test_ = nullptr; + loop_ = nullptr; } static gboolean SourceCallback(gpointer data) { @@ -85,7 +85,7 @@ class UpdateCheckSchedulerTest : public ::testing::Test { static UpdateCheckSchedulerTest* test_; }; -UpdateCheckSchedulerTest* UpdateCheckSchedulerTest::test_ = NULL; +UpdateCheckSchedulerTest* UpdateCheckSchedulerTest::test_ = nullptr; TEST_F(UpdateCheckSchedulerTest, CanScheduleTest) { EXPECT_FALSE(scheduler_.CanSchedule()); @@ -169,7 +169,7 @@ TEST_F(UpdateCheckSchedulerTest, RunBootDeviceRemovableTest) { fake_system_state_.fake_hardware()->SetIsBootDeviceRemovable(true); scheduler_.Run(); EXPECT_FALSE(scheduler_.enabled_); - EXPECT_EQ(NULL, attempter_.update_check_scheduler()); + EXPECT_EQ(nullptr, attempter_.update_check_scheduler()); } TEST_F(UpdateCheckSchedulerTest, RunNonOfficialBuildTest) { @@ -177,7 +177,7 @@ TEST_F(UpdateCheckSchedulerTest, RunNonOfficialBuildTest) { fake_system_state_.fake_hardware()->SetIsOfficialBuild(false); scheduler_.Run(); EXPECT_FALSE(scheduler_.enabled_); - EXPECT_EQ(NULL, attempter_.update_check_scheduler()); + EXPECT_EQ(nullptr, attempter_.update_check_scheduler()); } TEST_F(UpdateCheckSchedulerTest, RunTest) { @@ -268,7 +268,7 @@ TEST_F(UpdateCheckSchedulerTest, SetUpdateStatusNonIdleTest) { TEST_F(UpdateCheckSchedulerTest, StaticCheckOOBECompleteTest) { scheduler_.scheduled_ = true; - EXPECT_TRUE(scheduler_.fake_system_state_ != NULL); + EXPECT_NE(nullptr, scheduler_.fake_system_state_); scheduler_.fake_system_state_->fake_hardware()->SetIsOOBEComplete( Time::UnixEpoch()); EXPECT_CALL(attempter_, Update("", "", false, false)) diff --git a/update_engine_client.cc b/update_engine_client.cc index eb092b5..37d52d6 100644 --- a/update_engine_client.cc +++ b/update_engine_client.cc @@ -71,13 +71,13 @@ namespace { bool GetProxy(DBusGProxy** out_proxy) { DBusGConnection* bus; - DBusGProxy* proxy = NULL; - GError* error = NULL; + DBusGProxy* proxy = nullptr; + GError* error = nullptr; const int kTries = 4; const int kRetrySeconds = 10; bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); - if (bus == NULL) { + if (bus == nullptr) { LOG(ERROR) << "Failed to get bus: " << GetAndFreeGError(&error); exit(1); } @@ -96,7 +96,7 @@ bool GetProxy(DBusGProxy** out_proxy) { << kUpdateEngineServiceName << ": " << GetAndFreeGError(&error); } - if (proxy == NULL) { + if (proxy == nullptr) { LOG(ERROR) << "Giving up -- unable to get dbus proxy for " << kUpdateEngineServiceName; exit(1); @@ -122,7 +122,7 @@ static void StatusUpdateSignalHandler(DBusGProxy* proxy, bool ResetStatus() { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -131,18 +131,18 @@ bool ResetStatus() { } -// If |op| is non-NULL, sets it to the current operation string or an +// If |op| is non-null, sets it to the current operation string or an // empty string if unable to obtain the current status. bool GetStatus(string* op) { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); gint64 last_checked_time = 0; gdouble progress = 0.0; - char* current_op = NULL; - char* new_version = NULL; + char* current_op = nullptr; + char* new_version = nullptr; gint64 new_size = 0; gboolean rc = update_engine_client_get_status(proxy, @@ -194,19 +194,19 @@ void WatchForUpdates() { G_TYPE_STRING, G_TYPE_INT64, G_TYPE_INVALID); - GMainLoop* loop = g_main_loop_new(NULL, TRUE); + GMainLoop* loop = g_main_loop_new(nullptr, TRUE); dbus_g_proxy_connect_signal(proxy, kStatusUpdate, G_CALLBACK(StatusUpdateSignalHandler), - NULL, - NULL); + nullptr, + nullptr); g_main_loop_run(loop); g_main_loop_unref(loop); } bool Rollback(bool rollback) { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -220,7 +220,7 @@ bool Rollback(bool rollback) { std::string GetRollbackPartition() { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -254,7 +254,7 @@ std::string GetKernelDevices() { bool CheckForUpdates(const string& app_version, const string& omaha_url) { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -273,7 +273,7 @@ bool CheckForUpdates(const string& app_version, const string& omaha_url) { bool RebootIfNeeded() { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -288,7 +288,7 @@ bool RebootIfNeeded() { void SetTargetChannel(const string& target_channel, bool allow_powerwash) { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -303,11 +303,11 @@ void SetTargetChannel(const string& target_channel, bool allow_powerwash) { string GetChannel(bool get_current_channel) { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); - char* channel = NULL; + char* channel = nullptr; gboolean rc = update_engine_client_get_channel(proxy, get_current_channel, &channel, @@ -321,7 +321,7 @@ string GetChannel(bool get_current_channel) { void SetUpdateOverCellularPermission(gboolean allowed) { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -335,7 +335,7 @@ void SetUpdateOverCellularPermission(gboolean allowed) { bool GetUpdateOverCellularPermission() { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -351,7 +351,7 @@ bool GetUpdateOverCellularPermission() { void SetP2PUpdatePermission(gboolean enabled) { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -365,7 +365,7 @@ void SetP2PUpdatePermission(gboolean enabled) { bool GetP2PUpdatePermission() { DBusGProxy* proxy; - GError* error = NULL; + GError* error = nullptr; CHECK(GetProxy(&proxy)); @@ -396,8 +396,8 @@ static gboolean CompleteUpdateSource(gpointer data) { // a signal watch, actively poll the daemon just in case it stops // sending notifications. void CompleteUpdate() { - GMainLoop* loop = g_main_loop_new(NULL, TRUE); - g_timeout_add_seconds(5, CompleteUpdateSource, NULL); + GMainLoop* loop = g_main_loop_new(nullptr, TRUE); + g_timeout_add_seconds(5, CompleteUpdateSource, nullptr); g_main_loop_run(loop); g_main_loop_unref(loop); } @@ -663,7 +663,7 @@ int main(int argc, char** argv) { if (FLAGS_status) { LOG(INFO) << "Querying Update Engine status..."; - if (!GetStatus(NULL)) { + if (!GetStatus(nullptr)) { LOG(ERROR) << "GetStatus failed."; return 1; } diff --git a/update_manager/boxed_value.h b/update_manager/boxed_value.h index 4b8517f..6b547b6 100644 --- a/update_manager/boxed_value.h +++ b/update_manager/boxed_value.h @@ -43,7 +43,7 @@ class BoxedValue { // Creates an empty BoxedValue. Since the pointer can't be assigned from other // BoxedValues or pointers, this is only useful in places where a default // constructor is required, such as std::map::operator[]. - BoxedValue() : value_(NULL), deleter_(NULL), printer_(NULL) {} + BoxedValue() : value_(nullptr), deleter_(nullptr), printer_(nullptr) {} // Creates a BoxedValue for the passed pointer |value|. The BoxedValue keeps // the ownership of this pointer and can't be released. @@ -60,9 +60,9 @@ class BoxedValue { BoxedValue(BoxedValue&& other) // NOLINT(build/c++11) : value_(other.value_), deleter_(other.deleter_), printer_(other.printer_) { - other.value_ = NULL; - other.deleter_ = NULL; - other.printer_ = NULL; + other.value_ = nullptr; + other.deleter_ = nullptr; + other.printer_ = nullptr; } // Deletes the |value| passed on construction using the delete for the passed diff --git a/update_manager/boxed_value_unittest.cc b/update_manager/boxed_value_unittest.cc index 1b03cdd..dff6738 100644 --- a/update_manager/boxed_value_unittest.cc +++ b/update_manager/boxed_value_unittest.cc @@ -89,8 +89,8 @@ TEST(UmBoxedValueTest, MixedMap) { auto it = m.find(42); ASSERT_NE(it, m.end()); - UMTEST_EXPECT_NOT_NULL(it->second.value()); - UMTEST_EXPECT_NULL(m[33].value()); + EXPECT_NE(nullptr, it->second.value()); + EXPECT_EQ(nullptr, m[33].value()); } TEST(UmBoxedValueTest, StringToString) { diff --git a/update_manager/evaluation_context.cc b/update_manager/evaluation_context.cc index 5bee226..e334560 100644 --- a/update_manager/evaluation_context.cc +++ b/update_manager/evaluation_context.cc @@ -146,7 +146,7 @@ void EvaluationContext::ResetExpiration() { bool EvaluationContext::RunOnValueChangeOrTimeout(Closure callback) { // Check that the method was not called more than once. - if (callback_.get() != nullptr) { + if (callback_.get()) { LOG(ERROR) << "RunOnValueChangeOrTimeout called more than once."; return false; } diff --git a/update_manager/evaluation_context.h b/update_manager/evaluation_context.h index e743669..a6d8f70 100644 --- a/update_manager/evaluation_context.h +++ b/update_manager/evaluation_context.h @@ -70,7 +70,7 @@ class EvaluationContext : public base::RefCounted, // returned object is valid during the life of the evaluation, even if the // passed Variable changes it. // - // In case of error, a NULL value is returned. + // In case of error, a null value is returned. template const T* GetValue(Variable* var); diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc index e193718..e59b160 100644 --- a/update_manager/evaluation_context_unittest.cc +++ b/update_manager/evaluation_context_unittest.cc @@ -84,9 +84,9 @@ class UmEvaluationContextTest : public ::testing::Test { if (eval_ctx_) { base::WeakPtr eval_ctx_weak_alias = eval_ctx_->weak_ptr_factory_.GetWeakPtr(); - UMTEST_ASSERT_NOT_NULL(eval_ctx_weak_alias.get()); + ASSERT_NE(nullptr, eval_ctx_weak_alias.get()); eval_ctx_ = nullptr; - UMTEST_EXPECT_NULL(eval_ctx_weak_alias.get()) + EXPECT_EQ(nullptr, eval_ctx_weak_alias.get()) << "The evaluation context was not destroyed! This is likely a bug " "in how the test was written, look for leaking handles to the EC, " "possibly through closure objects."; @@ -120,13 +120,12 @@ class UmEvaluationContextTest : public ::testing::Test { }; TEST_F(UmEvaluationContextTest, GetValueFails) { - // FakeVariable is initialized as returning NULL. - UMTEST_EXPECT_NULL(eval_ctx_->GetValue(&fake_int_var_)); + // FakeVariable is initialized as returning null. + EXPECT_EQ(nullptr, eval_ctx_->GetValue(&fake_int_var_)); } TEST_F(UmEvaluationContextTest, GetValueFailsWithInvalidVar) { - UMTEST_EXPECT_NULL(eval_ctx_->GetValue( - reinterpret_cast*>(NULL))); + EXPECT_EQ(nullptr, eval_ctx_->GetValue(static_cast*>(nullptr))); } TEST_F(UmEvaluationContextTest, GetValueReturns) { @@ -134,7 +133,7 @@ TEST_F(UmEvaluationContextTest, GetValueReturns) { fake_int_var_.reset(new int(42)); p_fake_int = eval_ctx_->GetValue(&fake_int_var_); - UMTEST_ASSERT_NOT_NULL(p_fake_int); + ASSERT_NE(nullptr, p_fake_int); EXPECT_EQ(42, *p_fake_int); } @@ -149,19 +148,19 @@ TEST_F(UmEvaluationContextTest, GetValueCached) { fake_int_var_.reset(new int(5)); p_fake_int = eval_ctx_->GetValue(&fake_int_var_); - UMTEST_ASSERT_NOT_NULL(p_fake_int); + ASSERT_NE(nullptr, p_fake_int); EXPECT_EQ(42, *p_fake_int); } TEST_F(UmEvaluationContextTest, GetValueCachesNull) { const int* p_fake_int = eval_ctx_->GetValue(&fake_int_var_); - UMTEST_EXPECT_NULL(p_fake_int); + EXPECT_EQ(nullptr, p_fake_int); fake_int_var_.reset(new int(42)); // A second attempt to read the variable should not work because this - // EvaluationContext already got a NULL value. + // EvaluationContext already got a null value. p_fake_int = eval_ctx_->GetValue(&fake_int_var_); - UMTEST_EXPECT_NULL(p_fake_int); + EXPECT_EQ(nullptr, p_fake_int); } TEST_F(UmEvaluationContextTest, GetValueMixedTypes) { @@ -175,10 +174,10 @@ TEST_F(UmEvaluationContextTest, GetValueMixedTypes) { p_fake_int = eval_ctx_->GetValue(&fake_int_var_); p_fake_string = eval_ctx_->GetValue(&fake_poll_var_); - UMTEST_ASSERT_NOT_NULL(p_fake_int); + ASSERT_NE(nullptr, p_fake_int); EXPECT_EQ(42, *p_fake_int); - UMTEST_ASSERT_NOT_NULL(p_fake_string); + ASSERT_NE(nullptr, p_fake_string); EXPECT_EQ("Hello world!", *p_fake_string); } @@ -328,7 +327,7 @@ TEST_F(UmEvaluationContextTest, DefaultTimeout) { // setup. EXPECT_CALL(mock_var_async_, GetValue(default_timeout_, _)) .WillOnce(Return(nullptr)); - UMTEST_EXPECT_NULL(eval_ctx_->GetValue(&mock_var_async_)); + EXPECT_EQ(nullptr, eval_ctx_->GetValue(&mock_var_async_)); } TEST_F(UmEvaluationContextTest, TimeoutUpdatesWithMonotonicTime) { @@ -339,7 +338,7 @@ TEST_F(UmEvaluationContextTest, TimeoutUpdatesWithMonotonicTime) { EXPECT_CALL(mock_var_async_, GetValue(timeout, _)) .WillOnce(Return(nullptr)); - UMTEST_EXPECT_NULL(eval_ctx_->GetValue(&mock_var_async_)); + EXPECT_EQ(nullptr, eval_ctx_->GetValue(&mock_var_async_)); } TEST_F(UmEvaluationContextTest, ResetEvaluationResetsTimesWallclock) { diff --git a/update_manager/fake_variable.h b/update_manager/fake_variable.h index 6024b75..2dae3db 100644 --- a/update_manager/fake_variable.h +++ b/update_manager/fake_variable.h @@ -26,7 +26,8 @@ class FakeVariable : public Variable { // Sets the next value of this variable to the passed |p_value| pointer. Once // returned by GetValue(), the pointer is released and has to be set again. - // A value of NULL means that the GetValue() call will fail and return NULL. + // A value of null means that the GetValue() call will fail and return + // null. void reset(const T* p_value) { ptr_.reset(p_value); } @@ -40,11 +41,11 @@ class FakeVariable : public Variable { // Variable overrides. // Returns the pointer set with reset(). The ownership of the object is passed // to the caller and the pointer is release from the FakeVariable. A second - // call to GetValue() without reset() will return NULL and set the error + // call to GetValue() without reset() will return null and set the error // message. virtual const T* GetValue(base::TimeDelta /* timeout */, std::string* errmsg) { - if (ptr_ == NULL && errmsg != NULL) + if (ptr_ == nullptr && errmsg != nullptr) *errmsg = this->GetName() + " is an empty FakeVariable"; // Passes the pointer ownership to the caller. return ptr_.release(); diff --git a/update_manager/generic_variables_unittest.cc b/update_manager/generic_variables_unittest.cc index bbf3996..634acce 100644 --- a/update_manager/generic_variables_unittest.cc +++ b/update_manager/generic_variables_unittest.cc @@ -26,8 +26,8 @@ TEST_F(UmPollCopyVariableTest, SimpleTest) { // Generate and validate a copy. scoped_ptr copy_1(var.GetValue( - UmTestUtils::DefaultTimeout(), NULL)); - UMTEST_ASSERT_NOT_NULL(copy_1.get()); + UmTestUtils::DefaultTimeout(), nullptr)); + ASSERT_NE(nullptr, copy_1.get()); EXPECT_EQ(5, *copy_1); // Assign a different value to the source variable. @@ -76,8 +76,8 @@ TEST_F(UmPollCopyVariableTest, UseCopyConstructorTest) { PollCopyVariable var("var", source); scoped_ptr copy( - var.GetValue(UmTestUtils::DefaultTimeout(), NULL)); - UMTEST_ASSERT_NOT_NULL(copy.get()); + var.GetValue(UmTestUtils::DefaultTimeout(), nullptr)); + ASSERT_NE(nullptr, copy.get()); EXPECT_TRUE(copy->copied_); } @@ -117,7 +117,7 @@ TEST_F(UmCallCopyVariableTest, SimpleTest) { scoped_ptr copy( var.GetValue(UmTestUtils::DefaultTimeout(), nullptr)); EXPECT_EQ(6, test_obj.val_); // Check that the function was called. - UMTEST_ASSERT_NOT_NULL(copy.get()); + ASSERT_NE(nullptr, copy.get()); EXPECT_TRUE(copy->copied_); EXPECT_EQ(12, copy->val_); // Check that copying occurred once. } diff --git a/update_manager/real_config_provider_unittest.cc b/update_manager/real_config_provider_unittest.cc index fc20e36..93e657d 100644 --- a/update_manager/real_config_provider_unittest.cc +++ b/update_manager/real_config_provider_unittest.cc @@ -51,7 +51,7 @@ class UmRealConfigProviderTest : public ::testing::Test { TEST_F(UmRealConfigProviderTest, InitTest) { EXPECT_TRUE(provider_->Init()); - UMTEST_EXPECT_NOT_NULL(provider_->var_is_oobe_enabled()); + EXPECT_NE(nullptr, provider_->var_is_oobe_enabled()); } TEST_F(UmRealConfigProviderTest, NoFileFoundReturnsDefault) { diff --git a/update_manager/real_random_provider.cc b/update_manager/real_random_provider.cc index abbeed7..ea10de6 100644 --- a/update_manager/real_random_provider.cc +++ b/update_manager/real_random_provider.cc @@ -51,7 +51,7 @@ class RandomSeedVariable : public Variable { *errmsg = base::StringPrintf( "Error reading from the random device: %s", kRandomDevice); } - return NULL; + return nullptr; } buf_rd += rd; } diff --git a/update_manager/real_random_provider_unittest.cc b/update_manager/real_random_provider_unittest.cc index 55e17fa..b7e48f2 100644 --- a/update_manager/real_random_provider_unittest.cc +++ b/update_manager/real_random_provider_unittest.cc @@ -17,7 +17,7 @@ class UmRealRandomProviderTest : public ::testing::Test { virtual void SetUp() { // The provider initializes correctly. provider_.reset(new RealRandomProvider()); - UMTEST_ASSERT_NOT_NULL(provider_.get()); + ASSERT_NE(nullptr, provider_.get()); ASSERT_TRUE(provider_->Init()); provider_->var_seed(); @@ -28,14 +28,14 @@ class UmRealRandomProviderTest : public ::testing::Test { TEST_F(UmRealRandomProviderTest, InitFinalize) { // The provider initializes all variables with valid objects. - UMTEST_EXPECT_NOT_NULL(provider_->var_seed()); + EXPECT_NE(nullptr, provider_->var_seed()); } TEST_F(UmRealRandomProviderTest, GetRandomValues) { // Should not return the same random seed repeatedly. scoped_ptr value( provider_->var_seed()->GetValue(UmTestUtils::DefaultTimeout(), nullptr)); - UMTEST_ASSERT_NOT_NULL(value.get()); + ASSERT_NE(nullptr, value.get()); // Test that at least the returned values are different. This test fails, // by design, once every 2^320 runs. @@ -44,7 +44,7 @@ TEST_F(UmRealRandomProviderTest, GetRandomValues) { scoped_ptr other_value( provider_->var_seed()->GetValue(UmTestUtils::DefaultTimeout(), nullptr)); - UMTEST_ASSERT_NOT_NULL(other_value.get()); + ASSERT_NE(nullptr, other_value.get()); is_same_value = is_same_value && *other_value == *value; } EXPECT_FALSE(is_same_value); diff --git a/update_manager/real_shill_provider.cc b/update_manager/real_shill_provider.cc index dd8261c..609fd01 100644 --- a/update_manager/real_shill_provider.cc +++ b/update_manager/real_shill_provider.cc @@ -20,7 +20,7 @@ namespace { // the corresponding GValue, if found. const char* GetStrProperty(GHashTable* hash_table, const char* key) { auto gval = reinterpret_cast(g_hash_table_lookup(hash_table, key)); - return (gval ? g_value_get_string(gval) : NULL); + return (gval ? g_value_get_string(gval) : nullptr); } }; // namespace @@ -65,7 +65,7 @@ ConnectionTethering RealShillProvider::ParseConnectionTethering( bool RealShillProvider::Init() { // Obtain a DBus connection. - GError* error = NULL; + GError* error = nullptr; connection_ = dbus_->BusGet(DBUS_BUS_SYSTEM, &error); if (!connection_) { LOG(ERROR) << "Failed to initialize DBus connection: " @@ -82,12 +82,12 @@ bool RealShillProvider::Init() { G_TYPE_STRING, G_TYPE_VALUE); dbus_->ProxyConnectSignal(manager_proxy_, shill::kMonitorPropertyChanged, G_CALLBACK(HandlePropertyChangedStatic), - this, NULL); + this, nullptr); // Attempt to read initial connection status. Even if this fails because shill // is not responding (e.g. it is down) we'll be notified via "PropertyChanged" // signal as soon as it comes up, so this is not a critical step. - GHashTable* hash_table = NULL; + GHashTable* hash_table = nullptr; if (GetProperties(manager_proxy_, &hash_table)) { GValue* value = reinterpret_cast( g_hash_table_lookup(hash_table, shill::kDefaultServiceProperty)); @@ -106,7 +106,7 @@ DBusGProxy* RealShillProvider::GetProxy(const char* path, bool RealShillProvider::GetProperties(DBusGProxy* proxy, GHashTable** result_p) { - GError* error = NULL; + GError* error = nullptr; if (!dbus_->ProxyCall_0_1(proxy, shill::kGetPropertiesFunction, &error, result_p)) { LOG(ERROR) << "Calling shill via DBus proxy failed: " @@ -118,7 +118,7 @@ bool RealShillProvider::GetProperties(DBusGProxy* proxy, bool RealShillProvider::ProcessDefaultService(GValue* value) { // Decode the string from the boxed value. - const char* default_service_path_str = NULL; + const char* default_service_path_str = nullptr; if (!(value && (default_service_path_str = g_value_get_string(value)))) return false; @@ -136,7 +136,7 @@ bool RealShillProvider::ProcessDefaultService(GValue* value) { if (is_connected) { DBusGProxy* service_proxy = GetProxy(default_service_path_.c_str(), shill::kFlimflamServiceInterface); - GHashTable* hash_table = NULL; + GHashTable* hash_table = nullptr; if (GetProperties(service_proxy, &hash_table)) { // Get the connection type. const char* type_str = GetStrProperty(hash_table, shill::kTypeProperty); diff --git a/update_manager/real_shill_provider.h b/update_manager/real_shill_provider.h index 382aa1e..716a7dd 100644 --- a/update_manager/real_shill_provider.h +++ b/update_manager/real_shill_provider.h @@ -77,8 +77,8 @@ class RealShillProvider : public ShillProvider { // The DBus interface (mockable), connection, and a shill manager proxy. DBusWrapperInterface* const dbus_; - DBusGConnection* connection_ = NULL; - DBusGProxy* manager_proxy_ = NULL; + DBusGConnection* connection_ = nullptr; + DBusGProxy* manager_proxy_ = nullptr; // A clock abstraction (mockable). ClockInterface* const clock_; diff --git a/update_manager/real_shill_provider_unittest.cc b/update_manager/real_shill_provider_unittest.cc index 3468517..1cdc2a9 100644 --- a/update_manager/real_shill_provider_unittest.cc +++ b/update_manager/real_shill_provider_unittest.cc @@ -82,7 +82,7 @@ class UmRealShillProviderTest : public ::testing::Test { Shutdown(); provider_.reset(new RealShillProvider(&mock_dbus_, &fake_clock_)); - UMTEST_ASSERT_NOT_NULL(provider_.get()); + ASSERT_NE(nullptr, provider_.get()); fake_clock_.SetWallclockTime(InitTime()); // A DBus connection should only be obtained once. diff --git a/update_manager/real_system_provider_unittest.cc b/update_manager/real_system_provider_unittest.cc index d744671..f78d339 100644 --- a/update_manager/real_system_provider_unittest.cc +++ b/update_manager/real_system_provider_unittest.cc @@ -25,9 +25,9 @@ class UmRealSystemProviderTest : public ::testing::Test { }; TEST_F(UmRealSystemProviderTest, InitTest) { - UMTEST_EXPECT_NOT_NULL(provider_->var_is_normal_boot_mode()); - UMTEST_EXPECT_NOT_NULL(provider_->var_is_official_build()); - UMTEST_EXPECT_NOT_NULL(provider_->var_is_oobe_complete()); + EXPECT_NE(nullptr, provider_->var_is_normal_boot_mode()); + EXPECT_NE(nullptr, provider_->var_is_official_build()); + EXPECT_NE(nullptr, provider_->var_is_oobe_complete()); } TEST_F(UmRealSystemProviderTest, IsOOBECompleteTrue) { diff --git a/update_manager/real_time_provider_unittest.cc b/update_manager/real_time_provider_unittest.cc index 6b236db..ac47d39 100644 --- a/update_manager/real_time_provider_unittest.cc +++ b/update_manager/real_time_provider_unittest.cc @@ -22,7 +22,7 @@ class UmRealTimeProviderTest : public ::testing::Test { virtual void SetUp() { // The provider initializes correctly. provider_.reset(new RealTimeProvider(&fake_clock_)); - UMTEST_ASSERT_NOT_NULL(provider_.get()); + ASSERT_NE(nullptr, provider_.get()); ASSERT_TRUE(provider_->Init()); } diff --git a/update_manager/real_updater_provider.cc b/update_manager/real_updater_provider.cc index c525b8f..004b51a 100644 --- a/update_manager/real_updater_provider.cc +++ b/update_manager/real_updater_provider.cc @@ -81,7 +81,7 @@ class LastCheckedTimeVariable : public UpdaterVariableBase