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 <avakulenko@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/action.h b/action.h
index 27f1af9..c7fcba6 100644
--- a/action.h
+++ b/action.h
@@ -70,7 +70,7 @@
// 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 @@
namespace chromeos_update_engine {
ActionProcessor::ActionProcessor()
- : current_action_(NULL), delegate_(NULL) {}
+ : current_action_(nullptr), delegate_(nullptr) {}
ActionProcessor::~ActionProcessor() {
if (IsRunning()) {
@@ -20,7 +20,7 @@
}
for (std::deque<AbstractAction*>::iterator it = actions_.begin();
it != actions_.end(); ++it) {
- (*it)->SetProcessor(NULL);
+ (*it)->SetProcessor(nullptr);
}
}
@@ -45,10 +45,10 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
const vector<char>::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<Extent> 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 @@
}
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
connection,
&ChromeBrowserProxyResolver::StaticFilterMessage,
this,
- NULL));
+ nullptr));
proxy_ = dbus_->ProxyNewForName(bus, kLibCrosServiceName, kLibCrosServicePath,
kLibCrosServiceInterface);
@@ -92,7 +92,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
GValue* value = reinterpret_cast<GValue*>(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<GPtrArray*>(g_value_get_boxed(value))) &&
@@ -129,7 +129,7 @@
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 @@
GValue* value =
reinterpret_cast<GValue*>(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 @@
// Populate the out_type property.
value = reinterpret_cast<GValue*>(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<GValue*>(
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 @@
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 @@
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 @@
kMockSystemBus_ = reinterpret_cast<DBusGConnection*>(number++);
kMockFlimFlamManagerProxy_ = reinterpret_cast<DBusGProxy*>(number++);
kMockFlimFlamServiceProxy_ = reinterpret_cast<DBusGProxy*>(number++);
- ASSERT_NE(kMockSystemBus_, reinterpret_cast<DBusGConnection*>(NULL));
+ ASSERT_NE(kMockSystemBus_, static_cast<DBusGConnection*>(nullptr));
kServicePath_ = service_path;
@@ -91,7 +91,7 @@
// 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 @@
const_cast<char*>("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<char*>("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<char*>("Tethering"),
@@ -195,7 +195,7 @@
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 @@
}
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, 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 @@
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 @@
UpdateEngineService* update_engine_service_new(void) {
return reinterpret_cast<UpdateEngineService*>(
- 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 @@
// 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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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<int>(utils::FileSize(state->a_img));
@@ -357,7 +357,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
: 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 @@
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 @@
// 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::TerminateProcessing() {
if (writer_) {
writer_->Close();
- writer_ = NULL;
+ writer_ = nullptr;
}
if (delegate_) {
delegate_->SetDownloadStatus(false); // Set to inactive.
@@ -285,7 +285,7 @@
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 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 @@
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 @@
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 @@
ObjectFeederAction<InstallPlan> 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 @@
ObjectFeederAction<InstallPlan> 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 @@
class P2PDownloadActionTest : public testing::Test {
protected:
P2PDownloadActionTest()
- : loop_(NULL),
+ : loop_(nullptr),
start_at_offset_(0) {}
virtual ~P2PDownloadActionTest() {}
@@ -452,7 +452,7 @@
// Derived from testing::Test.
virtual void TearDown() {
- if (loop_ != NULL)
+ if (loop_ != nullptr)
g_main_loop_unref(loop_);
}
@@ -467,7 +467,7 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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, 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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
// 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 @@
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, 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 @@
(*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 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 @@
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 @@
}
HttpResponseCode StringToHttpResponseCode(const char *s) {
- return static_cast<HttpResponseCode>(strtoul(s, NULL, 10));
+ return static_cast<HttpResponseCode>(strtoul(s, nullptr, 10));
}
@@ -68,7 +68,7 @@
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 @@
utils::GlibDestroyClosure);
return true;
}
- CHECK_EQ(reinterpret_cast<Closure*>(NULL), callback_);
+ CHECK_EQ(static_cast<Closure*>(nullptr), callback_);
callback_ = callback;
return proxy_resolver_->GetProxiesForUrl(url,
&HttpFetcher::StaticProxiesResolved,
@@ -52,9 +52,9 @@
no_resolver_idle_id_ = 0;
if (!proxies.empty())
SetProxies(proxies);
- CHECK_NE(reinterpret_cast<Closure*>(NULL), callback_);
+ CHECK_NE(static_cast<Closure*>(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 @@
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 @@
// 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 @@
// Spawn the server process.
gchar *argv[] = {
const_cast<gchar*>("./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 @@
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 @@
class FailureHttpFetcherTestDelegate : public HttpFetcherDelegate {
public:
explicit FailureHttpFetcherTestDelegate(PythonHttpServer* server)
- : loop_(NULL),
+ : loop_(nullptr),
server_(server) {}
virtual ~FailureHttpFetcherTestDelegate() {
@@ -703,7 +705,7 @@
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 @@
return;
GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
{
- FailureHttpFetcherTestDelegate delegate(NULL);
+ FailureHttpFetcherTestDelegate delegate(nullptr);
delegate.loop_ = loop;
scoped_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
fetcher->set_delegate(&delegate);
@@ -906,7 +908,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
typedef std::map<int, std::pair<GIOChannel*, guint>> 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 @@
}
// 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 @@
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 @@
CHECK(!paused_);
bool ret = SendData(false);
if (false == ret) {
- timeout_source_ = NULL;
+ timeout_source_ = nullptr;
}
return ret;
}
@@ -96,7 +96,7 @@
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 @@
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 @@
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 @@
// 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 @@
void FreeCurrentBio() {
if (bio_) {
BIO_free_all(bio_);
- bio_ = NULL;
+ bio_ = nullptr;
}
}
@@ -114,13 +114,13 @@
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, 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, 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 @@
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 @@
// 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 @@
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 @@
}
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 @@
// 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 @@
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 @@
//
// 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 @@
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 @@
// 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<OmahaEvent> 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 @@
class OmahaRequestActionTestProcessorDelegate : public ActionProcessorDelegate {
public:
OmahaRequestActionTestProcessorDelegate()
- : loop_(NULL),
+ : loop_(nullptr),
expected_code_(ErrorCode::kSuccess) {}
virtual ~OmahaRequestActionTestProcessorDelegate() {
}
@@ -224,11 +224,11 @@
};
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
metrics::CheckReaction::kIgnored,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_FALSE(response.update_exists);
}
@@ -452,7 +452,7 @@
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 @@
.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 @@
metrics::CheckReaction::kIgnored,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_FALSE(response.update_exists);
}
@@ -498,10 +498,10 @@
.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 @@
metrics::CheckReaction::kIgnored,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_FALSE(response.update_exists);
}
@@ -529,10 +529,10 @@
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 @@
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_FALSE(response.update_exists);
}
@@ -564,9 +564,9 @@
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 @@
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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_TRUE(response.update_exists);
}
@@ -646,9 +646,9 @@
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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_TRUE(response.update_exists);
}
@@ -696,9 +696,9 @@
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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_TRUE(response.update_exists);
}
@@ -747,9 +747,9 @@
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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
int64_t count;
ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
@@ -801,9 +801,9 @@
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 @@
metrics::CheckReaction::kDeferring,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
int64_t count;
ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
@@ -837,9 +837,9 @@
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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_TRUE(response.update_exists);
}
@@ -889,9 +889,9 @@
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 @@
metrics::CheckReaction::kDeferring,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
int64_t count;
ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
@@ -927,9 +927,9 @@
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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_TRUE(response.update_exists);
}
@@ -964,10 +964,10 @@
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, 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 @@
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 @@
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,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response protocol=\"3.0\">"
"<daystart elapsed_seconds=\"100\"/>"
@@ -1041,17 +1041,17 @@
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,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response protocol=\"3.0\">"
"<daystart elapsed_seconds=\"100\"/>"
@@ -1065,17 +1065,17 @@
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,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response protocol=\"3.0\">"
"<daystart elapsed_seconds=\"100\"/>"
@@ -1089,7 +1089,7 @@
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_FALSE(response.update_exists);
}
@@ -1114,10 +1114,10 @@
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 @@
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 @@
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 @@
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, 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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_EQ(response.more_info_url, "testthe<url");
EXPECT_EQ(response.payload_urls[0], "testthe&codebase/file.signed");
@@ -1272,10 +1272,10 @@
TEST(OmahaRequestActionTest, ParseIntTest) {
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
@@ -1295,7 +1295,7 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_EQ(response.size, 123123123123123ll);
}
@@ -1307,9 +1307,9 @@
.WillOnce(DoAll(SetArgumentPointee<1>(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 @@
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 @@
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 @@
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 @@
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 @@
new OmahaEvent(OmahaEvent::kTypeUpdateComplete),
new MockHttpFetcher(http_response.data(),
http_response.size(),
- NULL),
+ nullptr),
false);
EXPECT_TRUE(event_action.IsEvent());
}
@@ -1459,10 +1459,10 @@
"", // 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 @@
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 @@
"", // 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 @@
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 @@
vector<char> 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 @@
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("<ping active=\"1\" a=\"6\" r=\"5\"></ping>"),
@@ -1612,9 +1612,9 @@
vector<char> 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 @@
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("<ping active=\"1\" a=\"3\"></ping>"),
@@ -1647,9 +1647,9 @@
vector<char> 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 @@
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("<ping active=\"1\" r=\"4\"></ping>\n"),
@@ -1683,9 +1683,9 @@
vector<char> 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 @@
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 @@
vector<char> 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 @@
metrics::CheckResult::kUnset,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
- NULL,
+ nullptr,
&post_data));
EXPECT_EQ(post_data.size(), 0);
}
@@ -1749,9 +1749,9 @@
vector<char> 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,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
"protocol=\"3.0\"><daystart elapsed_seconds=\"100\"/>"
@@ -1763,7 +1763,7 @@
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 @@
.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,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
"protocol=\"3.0\"><daystart elapsed_seconds=\"200\"/>"
@@ -1803,8 +1803,8 @@
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
- NULL,
- NULL));
+ nullptr,
+ nullptr));
}
TEST(OmahaRequestActionTest, NoElapsedSecondsTest) {
@@ -1815,9 +1815,9 @@
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,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
"protocol=\"3.0\"><daystart blah=\"200\"/>"
@@ -1829,8 +1829,8 @@
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
- NULL,
- NULL));
+ nullptr,
+ nullptr));
}
TEST(OmahaRequestActionTest, BadElapsedSecondsTest) {
@@ -1841,9 +1841,9 @@
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,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
"protocol=\"3.0\"><daystart elapsed_seconds=\"x\"/>"
@@ -1855,16 +1855,16 @@
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
- NULL,
- NULL));
+ nullptr,
+ nullptr));
}
TEST(OmahaRequestActionTest, NoUniqueIDTest) {
vector<char> 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 @@
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 @@
const int http_error_code =
static_cast<int>(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 @@
metrics::CheckReaction::kUnset,
static_cast<metrics::DownloadErrorCode>(501),
&response,
- NULL));
+ nullptr));
EXPECT_FALSE(response.update_exists);
}
@@ -1908,10 +1908,10 @@
const int http_error_code =
static_cast<int>(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 @@
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kHttpStatusOther,
&response,
- NULL));
+ nullptr));
EXPECT_FALSE(response.update_exists);
}
@@ -1943,9 +1943,9 @@
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 @@
metrics::CheckReaction::kDeferring,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
int64_t timestamp = 0;
ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateFirstSeenAt, ×tamp));
@@ -1979,9 +1979,9 @@
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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_TRUE(response.update_exists);
}
@@ -2031,9 +2031,9 @@
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 @@
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
&response,
- NULL));
+ nullptr));
EXPECT_TRUE(response.update_exists);
@@ -2095,9 +2095,9 @@
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 @@
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 @@
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 @@
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 @@
.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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
// 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 @@
}
}
- if (prefs_ != NULL &&
+ if (prefs_ != nullptr &&
prefs_->Exists(kPrefsP2PEnabled) &&
prefs_->GetBoolean(kPrefsP2PEnabled, &p2p_enabled) &&
p2p_enabled) {
@@ -218,19 +218,19 @@
}
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<string> args = configuration_->GetInitctlArgs(should_be_running);
scoped_ptr<gchar*, GLibStrvFreeDeleter> 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<GSpawnFlags>(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 @@
}
bool P2PManagerImpl::PerformHousekeeping() {
- GDir* dir = NULL;
- GError* error = NULL;
- const char* name = NULL;
+ GDir* dir = nullptr;
+ GError* error = nullptr;
+ const char* name = nullptr;
vector<pair<FilePath, Time> > 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 @@
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 @@
// 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<GSpawnFlags>(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 @@
GIOCondition condition,
gpointer user_data) {
LookupData *lookup_data = reinterpret_cast<LookupData*>(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 @@
delete lookup_data;
}
} else {
- if (str != NULL) {
+ if (str != nullptr) {
lookup_data->stdout_ += str;
g_free(str);
}
@@ -660,7 +660,7 @@
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 @@
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 @@
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 @@
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 @@
typedef base::Callback<void(const std::string& url)> 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 @@
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 @@
// 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 @@
// Check that we keep the $N newest files with the .$EXT.p2p extension.
TEST_F(P2PManagerTest, Housekeeping) {
scoped_ptr<P2PManager> 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 @@
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 @@
}
scoped_ptr<P2PManager> 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 @@
}
scoped_ptr<P2PManager> 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 @@
}
scoped_ptr<P2PManager> 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 @@
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 @@
// behaviours of initctl(8) that we rely on.
TEST_F(P2PManagerTest, StartP2P) {
scoped_ptr<P2PManager> 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 @@
// Same comment as for StartP2P
TEST_F(P2PManagerTest, StopP2P) {
scoped_ptr<P2PManager> 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 @@
// can return. It's not pretty but it works.
TEST_F(P2PManagerTest, LookupURL) {
scoped_ptr<P2PManager> 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 @@
// 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 @@
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 @@
}
}
}
- 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<char> compressed_data;
LOG(INFO) << "Reading compressed data off disk";
@@ -1385,7 +1385,7 @@
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 @@
TEST_AND_RETURN_FALSE(DeltaReadFile(graph,
cut.old_dst,
- NULL,
+ nullptr,
kEmptyPath,
new_root,
(*graph)[cut.old_dst].file_name,
@@ -1719,7 +1719,7 @@
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 @@
string patch_file_path;
TEST_AND_RETURN_FALSE(
- utils::MakeTempFile(kPatchFile, &patch_file_path, NULL));
+ utils::MakeTempFile(kPatchFile, &patch_file_path, nullptr));
vector<string> cmd;
cmd.push_back(kBsdiffPath);
@@ -1848,7 +1848,7 @@
int rc = 1;
vector<char> 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 @@
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, 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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
vector<string> 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 @@
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 @@
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 @@
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<ChunkProcessor*>(data)->ReadAndCompress() ? data : NULL;
+ return reinterpret_cast<ChunkProcessor*>(data)->ReadAndCompress() ?
+ data : nullptr;
}
bool ChunkProcessor::ReadAndCompress() {
@@ -161,7 +162,7 @@
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 @@
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 @@
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<char> buf(1024 * 1024);
@@ -378,7 +378,7 @@
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 all_blocks = ((ino == EXT2_JOURNAL_INO) || is_old_dir || is_new_dir);
vector<Extent> 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 @@
}
vector<Extent> 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 @@
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 @@
a_img,
b_img,
0,
- NULL));
+ nullptr));
EXPECT_EQ(graph.size(), 0);
CreateEmptyExtImageAtPath(a_img, 10485759, 4096);
@@ -60,17 +60,17 @@
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 @@
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 @@
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<char> signature;
@@ -193,7 +194,7 @@
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 @@
void SignSampleData(vector<char>* 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 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 @@
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 @@
}
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 @@
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 @@
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 @@
public:
PostinstallRunnerAction()
: powerwash_marker_created_(false),
- powerwash_marker_file_(NULL) {}
+ powerwash_marker_file_(nullptr) {}
void PerformAction();
@@ -44,8 +44,8 @@
// 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 PostinstActionProcessorDelegate : public ActionProcessorDelegate {
public:
PostinstActionProcessorDelegate()
- : loop_(NULL),
+ : loop_(nullptr),
code_(ErrorCode::kError),
code_set_(false) {}
void ProcessingDone(const ActionProcessor* processor,
@@ -218,7 +218,7 @@
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 @@
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 @@
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 @@
void FreeArgv(char** argv) {
for (int i = 0; argv[i]; i++) {
free(argv[i]);
- argv[i] = NULL;
+ argv[i] = nullptr;
}
}
@@ -86,7 +86,7 @@
}
// 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 @@
if (!ret[pointer]) {
FreeArgv(ret);
delete [] ret;
- return NULL;
+ return nullptr;
}
++pointer;
}
}
- ret[pointer] = NULL;
+ ret[pointer] = nullptr;
return ret;
}
@@ -131,15 +131,15 @@
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 @@
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 @@
// 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 @@
}
void Subprocess::CancelExec(uint32_t tag) {
- subprocess_records_[tag]->callback = NULL;
+ subprocess_records_[tag]->callback = nullptr;
}
bool Subprocess::SynchronousExecFlags(const vector<string>& cmd,
@@ -195,35 +195,35 @@
if (stdout) {
*stdout = "";
}
- GError* err = NULL;
+ GError* err = nullptr;
scoped_ptr<char*[]> 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<GSpawnFlags>(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 @@
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 @@
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 @@
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 @@
vector<string> 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 @@
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 @@
}
void RunGMainLoopUntil(int timeout_msec, base::Callback<bool()> 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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
update_check_fetcher->set_check_certificate(CertificateChecker::kUpdate);
shared_ptr<OmahaRequestAction> update_check_action(
new OmahaRequestAction(system_state_,
- NULL,
+ nullptr,
update_check_fetcher, // passes ownership
false));
shared_ptr<OmahaResponseHandlerAction> response_handler_action(
@@ -846,7 +846,7 @@
}
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 @@
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 @@
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 @@
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 @@
// 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 @@
}
bool UpdateAttempter::ScheduleErrorEventAction() {
- if (error_event_.get() == NULL)
+ if (error_event_.get() == nullptr)
return false;
LOG(ERROR) << "Update failed.";
@@ -1320,15 +1320,15 @@
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 @@
bool UpdateAttempter::ManageCpuSharesCallback() {
SetCpuShares(utils::kCpuSharesNormal);
- manage_shares_source_ = NULL;
+ manage_shares_source_ = nullptr;
return false; // Destroy the timeout source.
}
@@ -1402,12 +1402,12 @@
if (!processor_->IsRunning()) {
shared_ptr<OmahaRequestAction> ping_action(
new OmahaRequestAction(system_state_,
- NULL,
+ nullptr,
new LibcurlHttpFetcher(GetProxyResolver(),
system_state_),
true));
actions_.push_back(shared_ptr<OmahaRequestAction>(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 @@
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 @@
}
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::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 @@
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 @@
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 @@
};
TEST_F(UpdateAttempterTest, ActionCompletedDownloadTest) {
- scoped_ptr<MockHttpFetcher> fetcher(new MockHttpFetcher("", 0, NULL));
+ scoped_ptr<MockHttpFetcher> 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 @@
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<MockHttpFetcher> fetcher(new MockHttpFetcher("", 0, NULL));
+ scoped_ptr<MockHttpFetcher> 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<OmahaResponse> collector_action;
BondActions(&action, &collector_action);
@@ -203,18 +203,18 @@
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 @@
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 @@
attempter_.actions_[1].get());
DownloadAction* download_action =
dynamic_cast<DownloadAction*>(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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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<UpdateAttempterTest*>(data);
@@ -751,7 +751,7 @@
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 @@
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 @@
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<UpdateAttempterTest*>(data);
@@ -834,7 +834,7 @@
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<UpdateAttempterTest*>(data);
@@ -862,7 +862,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
virtual void TearDown() {
- test_ = NULL;
- loop_ = NULL;
+ test_ = nullptr;
+ loop_ = nullptr;
}
static gboolean SourceCallback(gpointer data) {
@@ -85,7 +85,7 @@
static UpdateCheckSchedulerTest* test_;
};
-UpdateCheckSchedulerTest* UpdateCheckSchedulerTest::test_ = NULL;
+UpdateCheckSchedulerTest* UpdateCheckSchedulerTest::test_ = nullptr;
TEST_F(UpdateCheckSchedulerTest, CanScheduleTest) {
EXPECT_FALSE(scheduler_.CanSchedule());
@@ -169,7 +169,7 @@
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 @@
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, 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 @@
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 @@
<< 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 @@
bool ResetStatus() {
DBusGProxy* proxy;
- GError* error = NULL;
+ GError* error = nullptr;
CHECK(GetProxy(&proxy));
@@ -131,18 +131,18 @@
}
-// 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 @@
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 @@
std::string GetRollbackPartition() {
DBusGProxy* proxy;
- GError* error = NULL;
+ GError* error = nullptr;
CHECK(GetProxy(&proxy));
@@ -254,7 +254,7 @@
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 RebootIfNeeded() {
DBusGProxy* proxy;
- GError* error = NULL;
+ GError* error = nullptr;
CHECK(GetProxy(&proxy));
@@ -288,7 +288,7 @@
void SetTargetChannel(const string& target_channel, bool allow_powerwash) {
DBusGProxy* proxy;
- GError* error = NULL;
+ GError* error = nullptr;
CHECK(GetProxy(&proxy));
@@ -303,11 +303,11 @@
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 @@
void SetUpdateOverCellularPermission(gboolean allowed) {
DBusGProxy* proxy;
- GError* error = NULL;
+ GError* error = nullptr;
CHECK(GetProxy(&proxy));
@@ -335,7 +335,7 @@
bool GetUpdateOverCellularPermission() {
DBusGProxy* proxy;
- GError* error = NULL;
+ GError* error = nullptr;
CHECK(GetProxy(&proxy));
@@ -351,7 +351,7 @@
void SetP2PUpdatePermission(gboolean enabled) {
DBusGProxy* proxy;
- GError* error = NULL;
+ GError* error = nullptr;
CHECK(GetProxy(&proxy));
@@ -365,7 +365,7 @@
bool GetP2PUpdatePermission() {
DBusGProxy* proxy;
- GError* error = NULL;
+ GError* error = nullptr;
CHECK(GetProxy(&proxy));
@@ -396,8 +396,8 @@
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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<typename T>
const T* GetValue(Variable<T>* 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 @@
if (eval_ctx_) {
base::WeakPtr<EvaluationContext> 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 @@
};
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<Variable<int>*>(NULL)));
+ EXPECT_EQ(nullptr, eval_ctx_->GetValue(static_cast<Variable<int>*>(nullptr)));
}
TEST_F(UmEvaluationContextTest, GetValueReturns) {
@@ -134,7 +133,7 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
// 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 @@
// Variable<T> 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 @@
// Generate and validate a copy.
scoped_ptr<const int> 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 @@
PollCopyVariable<CopyConstructorTestClass> var("var", source);
scoped_ptr<const CopyConstructorTestClass> 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 @@
scoped_ptr<const CopyConstructorTestClass> 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 @@
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 @@
*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 @@
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 @@
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<const uint64_t> 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 @@
scoped_ptr<const uint64_t> 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 @@
// the corresponding GValue, if found.
const char* GetStrProperty(GHashTable* hash_table, const char* key) {
auto gval = reinterpret_cast<GValue*>(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 @@
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 @@
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<GValue*>(
g_hash_table_lookup(hash_table, shill::kDefaultServiceProperty));
@@ -106,7 +106,7 @@
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::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 @@
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 @@
// 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 @@
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 @@
};
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 @@
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 @@
const Time* GetValue(TimeDelta /* timeout */, string* errmsg) override {
GetStatusHelper raw(system_state(), errmsg);
if (!raw.is_success())
- return NULL;
+ return nullptr;
return new Time(Time::FromTimeT(raw.last_checked_time()));
}
@@ -100,14 +100,14 @@
const double* GetValue(TimeDelta /* timeout */, string* errmsg) override {
GetStatusHelper raw(system_state(), errmsg);
if (!raw.is_success())
- return NULL;
+ return nullptr;
if (raw.progress() < 0.0 || raw.progress() > 1.0) {
if (errmsg) {
*errmsg = StringPrintf("Invalid progress value received: %f",
raw.progress());
}
- return NULL;
+ return nullptr;
}
return new double(raw.progress());
@@ -154,7 +154,7 @@
string* errmsg) {
GetStatusHelper raw(system_state(), errmsg);
if (!raw.is_success())
- return NULL;
+ return nullptr;
for (auto& key_val : curr_op_str_to_stage)
if (raw.update_status() == key_val.str)
@@ -162,7 +162,7 @@
if (errmsg)
*errmsg = string("Unknown update status: ") + raw.update_status();
- return NULL;
+ return nullptr;
}
// A variable reporting the version number that an update is updating to.
@@ -175,7 +175,7 @@
const string* GetValue(TimeDelta /* timeout */, string* errmsg) override {
GetStatusHelper raw(system_state(), errmsg);
if (!raw.is_success())
- return NULL;
+ return nullptr;
return new string(raw.new_version());
}
@@ -193,12 +193,12 @@
const int64_t* GetValue(TimeDelta /* timeout */, string* errmsg) override {
GetStatusHelper raw(system_state(), errmsg);
if (!raw.is_success())
- return NULL;
+ return nullptr;
if (raw.payload_size() < 0) {
if (errmsg)
*errmsg = string("Invalid payload size: %" PRId64, raw.payload_size());
- return NULL;
+ return nullptr;
}
return new int64_t(raw.payload_size());
@@ -226,7 +226,7 @@
&update_boottime)) {
if (errmsg)
*errmsg = "Update completed time could not be read";
- return NULL;
+ return nullptr;
}
chromeos_update_engine::ClockInterface* clock = system_state()->clock();
@@ -234,7 +234,7 @@
if (curr_boottime < update_boottime) {
if (errmsg)
*errmsg = "Update completed time more recent than current time";
- return NULL;
+ return nullptr;
}
TimeDelta duration_since_update = curr_boottime - update_boottime;
return new Time(clock->GetWallclockTime() - duration_since_update);
@@ -256,7 +256,7 @@
if (channel.empty()) {
if (errmsg)
*errmsg = "No current channel";
- return NULL;
+ return nullptr;
}
return new string(channel);
}
@@ -277,7 +277,7 @@
if (channel.empty()) {
if (errmsg)
*errmsg = "No new channel";
- return NULL;
+ return nullptr;
}
return new string(channel);
}
@@ -300,7 +300,7 @@
if (prefs && prefs->Exists(key_) && !prefs->GetBoolean(key_, &result)) {
if (errmsg)
*errmsg = string("Could not read boolean pref ") + key_;
- return NULL;
+ return nullptr;
}
return new bool(result);
}
diff --git a/update_manager/real_updater_provider_unittest.cc b/update_manager/real_updater_provider_unittest.cc
index 6e34fe4..6d614da 100644
--- a/update_manager/real_updater_provider_unittest.cc
+++ b/update_manager/real_updater_provider_unittest.cc
@@ -65,7 +65,7 @@
virtual void SetUp() {
fake_clock_ = fake_sys_state_.fake_clock();
provider_.reset(new RealUpdaterProvider(&fake_sys_state_));
- UMTEST_ASSERT_NOT_NULL(provider_.get());
+ ASSERT_NE(nullptr, provider_.get());
// Check that provider initializes correctly.
ASSERT_TRUE(provider_->Init());
}
diff --git a/update_manager/state_factory.cc b/update_manager/state_factory.cc
index 6aa1761..e9b576a 100644
--- a/update_manager/state_factory.cc
+++ b/update_manager/state_factory.cc
@@ -44,7 +44,7 @@
time_provider->Init() &&
updater_provider->Init())) {
LOG(ERROR) << "Error initializing providers";
- return NULL;
+ return nullptr;
}
return new RealState(config_provider.release(),
diff --git a/update_manager/umtest_utils.h b/update_manager/umtest_utils.h
index 3c9036e..4e2de8e 100644
--- a/update_manager/umtest_utils.h
+++ b/update_manager/umtest_utils.h
@@ -14,22 +14,6 @@
#include "update_engine/update_manager/policy.h"
#include "update_engine/update_manager/variable.h"
-// Convenience macros for checking null-ness of pointers.
-//
-// Purportedly, gtest should support pointer comparison when the first argument
-// is a pointer (e.g. NULL). It is therefore appropriate to use
-// {ASSERT,EXPECT}_{EQ,NE} for our purposes. However, gtest fails to realize
-// that NULL is a pointer when used with the _NE variants, unless we explicitly
-// cast it to a pointer type, and so we inject this casting.
-//
-// Note that checking nullness of the content of a scoped_ptr requires getting
-// the inner pointer value via get().
-#define UMTEST_ASSERT_NULL(p) ASSERT_EQ(NULL, p)
-#define UMTEST_ASSERT_NOT_NULL(p) ASSERT_NE(reinterpret_cast<void*>(NULL), p)
-#define UMTEST_EXPECT_NULL(p) EXPECT_EQ(NULL, p)
-#define UMTEST_EXPECT_NOT_NULL(p) EXPECT_NE(reinterpret_cast<void*>(NULL), p)
-
-
namespace chromeos_update_manager {
// A help class with common functionality for use in Update Manager testing.
@@ -43,18 +27,18 @@
// Calls GetValue on |variable| and expects its result to be |expected|.
template<typename T>
static void ExpectVariableHasValue(const T& expected, Variable<T>* variable) {
- UMTEST_ASSERT_NOT_NULL(variable);
+ ASSERT_NE(nullptr, variable);
scoped_ptr<const T> value(variable->GetValue(DefaultTimeout(), nullptr));
- UMTEST_ASSERT_NOT_NULL(value.get()) << "Variable: " << variable->GetName();
+ ASSERT_NE(nullptr, value.get()) << "Variable: " << variable->GetName();
EXPECT_EQ(expected, *value) << "Variable: " << variable->GetName();
}
// Calls GetValue on |variable| and expects its result to be null.
template<typename T>
static void ExpectVariableNotSet(Variable<T>* variable) {
- UMTEST_ASSERT_NOT_NULL(variable);
+ ASSERT_NE(nullptr, variable);
scoped_ptr<const T> value(variable->GetValue(DefaultTimeout(), nullptr));
- UMTEST_EXPECT_NULL(value.get()) << "Variable: " << variable->GetName();
+ EXPECT_EQ(nullptr, value.get()) << "Variable: " << variable->GetName();
}
private:
diff --git a/update_manager/update_manager.h b/update_manager/update_manager.h
index 8cfd8f4..3355b60 100644
--- a/update_manager/update_manager.h
+++ b/update_manager/update_manager.h
@@ -44,8 +44,8 @@
// PolicyRequest() evaluates the given policy with the provided arguments and
// returns the result. The |policy_method| is the pointer-to-method of the
// Policy class for the policy request to call. The UpdateManager will call
- // this method on the right policy. The pointer |result| must not be NULL and
- // the remaining |args| depend on the arguments required by the passed
+ // this method on the right policy. The pointer |result| must not be null
+ // and the remaining |args| depend on the arguments required by the passed
// |policy_method|.
//
// When the policy request succeeds, the |result| is set and the method
diff --git a/update_manager/variable.h b/update_manager/variable.h
index e90d07e..ad2eefa 100644
--- a/update_manager/variable.h
+++ b/update_manager/variable.h
@@ -188,9 +188,9 @@
// should delete it.
//
// In case of and error getting the current value or the |timeout| timeout is
- // exceeded, a NULL value is returned and the |errmsg| is set.
+ // exceeded, a null value is returned and the |errmsg| is set.
//
- // The caller can pass a NULL value for |errmsg|, in which case the error
+ // The caller can pass a null value for |errmsg|, in which case the error
// message won't be set.
virtual const T* GetValue(base::TimeDelta timeout, std::string* errmsg) = 0;
diff --git a/utils.cc b/utils.cc
index ed57c14..6c527b3 100644
--- a/utils.cc
+++ b/utils.cc
@@ -323,8 +323,8 @@
if (dir_ && *dir_) {
int r = closedir(*dir_);
TEST_AND_RETURN_ERRNO(r == 0);
- *dir_ = NULL;
- dir_ = NULL;
+ *dir_ = nullptr;
+ dir_ = nullptr;
}
}
private:
@@ -354,7 +354,7 @@
struct dirent *dir_entry_p;
int err = 0;
while ((err = readdir_r(dir, &dir_entry, &dir_entry_p)) == 0) {
- if (dir_entry_p == NULL) {
+ if (dir_entry_p == nullptr) {
// end of stream reached
break;
}
@@ -575,7 +575,7 @@
buf[dirname_template.size()] = '\0';
char* return_code = mkdtemp(&buf[0]);
- TEST_AND_RETURN_FALSE_ERRNO(return_code != NULL);
+ TEST_AND_RETURN_FALSE_ERRNO(return_code != nullptr);
*dirname = &buf[0];
return true;
}
@@ -595,7 +595,8 @@
bool MountFilesystem(const string& device,
const string& mountpoint,
unsigned long mountflags) { // NOLINT(runtime/int)
- int rc = mount(device.c_str(), mountpoint.c_str(), "ext3", mountflags, NULL);
+ int rc = mount(device.c_str(), mountpoint.c_str(), "ext3", mountflags,
+ nullptr);
if (rc < 0) {
string msg = ErrnoNumberAsString(errno);
LOG(ERROR) << "Unable to mount destination device: " << msg << ". "
@@ -792,14 +793,14 @@
abort(); // never returns
}
// We are the parent. Wait for child to terminate.
- pid_t result = waitpid(pid, NULL, 0);
+ pid_t result = waitpid(pid, nullptr, 0);
LOG_IF(ERROR, result < 0) << "waitpid() failed";
return FALSE; // Don't call this callback again
}
} // namespace
void ScheduleCrashReporterUpload() {
- g_idle_add(&TriggerCrashReporterUpload, NULL);
+ g_idle_add(&TriggerCrashReporterUpload, nullptr);
}
bool SetCpuShares(CpuShares shares) {
@@ -1401,7 +1402,7 @@
i != vector.end(); ++i) {
g_ptr_array_add(p, g_strdup(i->c_str()));
}
- g_ptr_array_add(p, NULL);
+ g_ptr_array_add(p, nullptr);
return reinterpret_cast<gchar**>(g_ptr_array_free(p, FALSE));
}
@@ -1477,7 +1478,7 @@
}
FILE *file = base::CreateAndOpenTemporaryFile(out_path);
- if (file == NULL) {
+ if (file == nullptr) {
LOG(ERROR) << "Error creating temporary file.";
return false;
}
diff --git a/utils.h b/utils.h
index 6d14fbc..a526ccd 100644
--- a/utils.h
+++ b/utils.h
@@ -37,7 +37,7 @@
// down.
base::Time TimeFromStructTimespec(struct timespec *ts);
-// Converts a vector of strings to a NULL-terminated array of
+// Converts a vector of strings to a NUL-terminated array of
// strings. The resulting array should be freed with g_strfreev()
// when are you done with it.
gchar** StringVectorToGStrv(const std::vector<std::string> &vector);
@@ -114,9 +114,9 @@
// "../"), then it is prepended the value of TMPDIR, which defaults to /tmp if
// it isn't set or is empty. It then calls mkstemp(3) with the resulting
// template. Writes the name of a new temporary file to |filename|. If |fd| is
-// non-NULL, the file descriptor returned by mkstemp is written to it and kept
-// open; otherwise, it is closed. The template must end with "XXXXXX". Returns
-// true on success.
+// non-null, the file descriptor returned by mkstemp is written to it and
+// kept open; otherwise, it is closed. The template must end with "XXXXXX".
+// Returns true on success.
bool MakeTempFile(const std::string& base_filename_template,
std::string* filename,
int* fd);
@@ -149,7 +149,7 @@
// number. For example, "/dev/sda3" will be split into {"/dev/sda", 3} and
// "/dev/mmcblk0p2" into {"/dev/mmcblk0", 2}
// Returns false when malformed device name is passed in.
-// If both output parameters are omitted (nullptr), can be used
+// If both output parameters are omitted (null), can be used
// just to test the validity of the device name. Note that the function
// simply checks if the device name looks like a valid device, no other
// checks are performed (i.e. it doesn't check if the device actually exists).
@@ -363,12 +363,12 @@
std::string CodeToString(ErrorCode code);
// Creates the powerwash marker file with the appropriate commands in it. Uses
-// |file_path| as the path to the marker file if non-NULL, otherwise uses the
+// |file_path| as the path to the marker file if non-null, otherwise uses the
// global default. Returns true if successfully created. False otherwise.
bool CreatePowerwashMarkerFile(const char* file_path);
// Deletes the marker file used to trigger Powerwash using clobber-state. Uses
-// |file_path| as the path to the marker file if non-NULL, otherwise uses the
+// |file_path| as the path to the marker file if non-null, otherwise uses the
// global default. Returns true if successfully deleted. False otherwise.
bool DeletePowerwashMarkerFile(const char* file_path);
diff --git a/utils_unittest.cc b/utils_unittest.cc
index f23dd5c..4618beb 100644
--- a/utils_unittest.cc
+++ b/utils_unittest.cc
@@ -315,9 +315,9 @@
TEST(UtilsTest, RunAsRootGetFilesystemSizeTest) {
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",