Convert 0 and NULL to nullptr in components.
Steps to replicate:
1. Build clang-tidy and clang-apply-replacements as described here: https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md
2. Build targets necessary for the change in out/gn.
3. Generate the compilation database:
tools/clang/scripts/generate_compdb.py -p out/gn > compile_commands.json
4. Run clang-tidy and apply replacements:
cd out/gn && PATH_TO_RUN_CLANG_TIDY/run-clang-tidy.py -p ../../ -clang-tidy-binary PATH_TO_CLANG_TIDY_BINARY -clang-apply-replacements-binary PATH_TO_CLANG_APPLY_REPLACEMENTS_BINARY -checks=-*,modernize-use-nullptr -fix -j 8 DIR_TO_CONVERT
Bug: 403854, 776257
Change-Id: Ifd0c147ac6866beacffbddb0c56b20502cb4f127
Reviewed-on: https://chromium-review.googlesource.com/732308
Reviewed-by: Jochen Eisinger <[email protected]>
Commit-Queue: Ivan Kotenkov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#511144}
diff --git a/components/update_client/component_patcher.cc b/components/update_client/component_patcher.cc
index a69860c5..b7905b7 100644
--- a/components/update_client/component_patcher.cc
+++ b/components/update_client/component_patcher.cc
@@ -30,14 +30,15 @@
const base::FilePath commands =
unpack_path.Append(FILE_PATH_LITERAL("commands.json"));
if (!base::PathExists(commands))
- return NULL;
+ return nullptr;
JSONFileValueDeserializer deserializer(commands);
- std::unique_ptr<base::Value> root = deserializer.Deserialize(NULL, NULL);
+ std::unique_ptr<base::Value> root =
+ deserializer.Deserialize(nullptr, nullptr);
return (root.get() && root->IsType(base::Value::Type::LIST))
? static_cast<base::ListValue*>(root.release())
- : NULL;
+ : nullptr;
}
} // namespace
@@ -109,7 +110,7 @@
}
void ComponentPatcher::DonePatching(UnpackerError error, int extended_error) {
- current_operation_ = NULL;
+ current_operation_ = nullptr;
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(callback_, error, extended_error));
callback_.Reset();
diff --git a/components/update_client/component_patcher_operation.cc b/components/update_client/component_patcher_operation.cc
index 6fbde6b..0cfc8aa 100644
--- a/components/update_client/component_patcher_operation.cc
+++ b/components/update_client/component_patcher_operation.cc
@@ -50,7 +50,7 @@
} else if (operation == "bsdiff" || operation == "courgette") {
return new DeltaUpdateOpPatch(operation, out_of_process_patcher);
}
- return NULL;
+ return nullptr;
}
DeltaUpdateOp::DeltaUpdateOp() {
diff --git a/components/update_client/component_patcher_unittest.cc b/components/update_client/component_patcher_unittest.cc
index b6dfe2c..21bb34a 100644
--- a/components/update_client/component_patcher_unittest.cc
+++ b/components/update_client/component_patcher_unittest.cc
@@ -90,8 +90,8 @@
TestCallback callback;
scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCreate();
- op->Run(command_args.get(), input_dir_.GetPath(), unpack_dir_.GetPath(), NULL,
- base::Bind(&TestCallback::Set, base::Unretained(&callback)));
+ op->Run(command_args.get(), input_dir_.GetPath(), unpack_dir_.GetPath(),
+ nullptr, base::Bind(&TestCallback::Set, base::Unretained(&callback)));
scoped_task_environment_.RunUntilIdle();
EXPECT_EQ(true, callback.called_);
@@ -149,7 +149,7 @@
TestCallback callback;
scoped_refptr<DeltaUpdateOp> op =
- CreateDeltaUpdateOp("courgette", NULL /* out_of_process_patcher */);
+ CreateDeltaUpdateOp("courgette", nullptr /* out_of_process_patcher */);
op->Run(command_args.get(), input_dir_.GetPath(), unpack_dir_.GetPath(),
installer_.get(),
base::Bind(&TestCallback::Set, base::Unretained(&callback)));
@@ -182,7 +182,7 @@
TestCallback callback;
scoped_refptr<DeltaUpdateOp> op =
- CreateDeltaUpdateOp("bsdiff", NULL /* out_of_process_patcher */);
+ CreateDeltaUpdateOp("bsdiff", nullptr /* out_of_process_patcher */);
op->Run(command_args.get(), input_dir_.GetPath(), unpack_dir_.GetPath(),
installer_.get(),
base::Bind(&TestCallback::Set, base::Unretained(&callback)));
diff --git a/components/update_client/component_unpacker.cc b/components/update_client/component_unpacker.cc
index 129143555..5e64762 100644
--- a/components/update_client/component_unpacker.cc
+++ b/components/update_client/component_unpacker.cc
@@ -121,7 +121,7 @@
void ComponentUnpacker::EndPatching(UnpackerError error, int extended_error) {
error_ = error;
extended_error_ = extended_error;
- patcher_ = NULL;
+ patcher_ = nullptr;
EndUnpacking();
}
diff --git a/components/update_client/crx_downloader_unittest.cc b/components/update_client/crx_downloader_unittest.cc
index 40440085..ae83dc18 100644
--- a/components/update_client/crx_downloader_unittest.cc
+++ b/components/update_client/crx_downloader_unittest.cc
@@ -108,7 +108,7 @@
base::ThreadTaskRunnerHandle::Get())) {}
CrxDownloaderTest::~CrxDownloaderTest() {
- context_ = NULL;
+ context_ = nullptr;
// The GetInterceptor requires the message loop to run to destruct correctly.
get_interceptor_.reset();
diff --git a/components/update_client/protocol_parser.cc b/components/update_client/protocol_parser.cc
index 74527d4..4fd3c99 100644
--- a/components/update_client/protocol_parser.cc
+++ b/components/update_client/protocol_parser.cc
@@ -64,7 +64,7 @@
// Returns child nodes of |root| with name |name|.
static std::vector<xmlNode*> GetChildren(xmlNode* root, const char* name) {
std::vector<xmlNode*> result;
- for (xmlNode* child = root->children; child != NULL; child = child->next) {
+ for (xmlNode* child = root->children; child != nullptr; child = child->next) {
if (!TagNameEquals(child, name)) {
continue;
}
@@ -76,7 +76,7 @@
// Returns the value of a named attribute, or the empty string.
static std::string GetAttribute(xmlNode* node, const char* attribute_name) {
const xmlChar* name = reinterpret_cast<const xmlChar*>(attribute_name);
- for (xmlAttr* attr = node->properties; attr != NULL; attr = attr->next) {
+ for (xmlAttr* attr = node->properties; attr != nullptr; attr = attr->next) {
if (!xmlStrcmp(attr->name, name) && attr->children &&
attr->children->content) {
return std::string(
@@ -91,7 +91,7 @@
xmlNode* node,
const char* attribute_name) {
const xmlChar* name = reinterpret_cast<const xmlChar*>(attribute_name);
- for (xmlAttr* attr = node->properties; attr != NULL; attr = attr->next) {
+ for (xmlAttr* attr = node->properties; attr != nullptr; attr = attr->next) {
if (!xmlStrcmp(attr->name, name) && attr->children &&
attr->children->content) {
return base::MakeUnique<std::string>(
diff --git a/components/update_client/test_configurator.cc b/components/update_client/test_configurator.cc
index 4dd09d0..810364a5 100644
--- a/components/update_client/test_configurator.cc
+++ b/components/update_client/test_configurator.cc
@@ -108,7 +108,7 @@
scoped_refptr<OutOfProcessPatcher> TestConfigurator::CreateOutOfProcessPatcher()
const {
- return NULL;
+ return nullptr;
}
bool TestConfigurator::EnabledDeltas() const {
diff --git a/components/update_client/update_checker_unittest.cc b/components/update_client/update_checker_unittest.cc
index f384f0e..4306b34 100644
--- a/components/update_client/update_checker_unittest.cc
+++ b/components/update_client/update_checker_unittest.cc
@@ -220,7 +220,7 @@
CrxComponent crx_component;
crx_component.name = "test_jebg";
crx_component.pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
- crx_component.installer = NULL;
+ crx_component.installer = nullptr;
crx_component.version = base::Version("0.9");
crx_component.fingerprint = "fp1";
diff --git a/components/update_client/update_query_params.cc b/components/update_client/update_query_params.cc
index 65d53ba..319d59e 100644
--- a/components/update_client/update_query_params.cc
+++ b/components/update_client/update_query_params.cc
@@ -66,7 +66,7 @@
const char kChromiumCrx[] = "chromiumcrx";
#endif // defined(GOOGLE_CHROME_BUILD)
-UpdateQueryParamsDelegate* g_delegate = NULL;
+UpdateQueryParamsDelegate* g_delegate = nullptr;
} // namespace
diff --git a/components/update_client/url_request_post_interceptor.cc b/components/update_client/url_request_post_interceptor.cc
index 50bf037..6367b49 100644
--- a/components/update_client/url_request_post_interceptor.cc
+++ b/components/update_client/url_request_post_interceptor.cc
@@ -185,7 +185,7 @@
// Only intercepts POST.
if (!request->has_upload())
- return NULL;
+ return nullptr;
GURL url = request->url();
if (url.has_query()) {
@@ -196,7 +196,7 @@
InterceptorMap::const_iterator it(interceptors_.find(url));
if (it == interceptors_.end())
- return NULL;
+ return nullptr;
// There is an interceptor hooked up for this url. Read the request body,
// check the existing expectations, and handle the matching case by
@@ -215,7 +215,7 @@
base::AutoLock auto_lock(interceptor->interceptor_lock_);
interceptor->requests_.push_back(request_body);
if (interceptor->expectations_.empty())
- return NULL;
+ return nullptr;
const URLRequestPostInterceptor::Expectation& expectation(
interceptor->expectations_.front());
if (expectation.first->Match(request_body)) {
@@ -230,7 +230,7 @@
}
}
- return NULL;
+ return nullptr;
}
typedef std::map<GURL, URLRequestPostInterceptor*> InterceptorMap;
@@ -277,7 +277,7 @@
base::Unretained(delegate_), base::Unretained(interceptor)));
if (!res) {
delete interceptor;
- return NULL;
+ return nullptr;
}
return interceptor;
diff --git a/components/update_client/utils.cc b/components/update_client/utils.cc
index 2571687..252841d8 100644
--- a/components/update_client/utils.cc
+++ b/components/update_client/utils.cc
@@ -264,7 +264,7 @@
return std::unique_ptr<base::DictionaryValue>();
JSONFileValueDeserializer deserializer(manifest);
std::string error;
- std::unique_ptr<base::Value> root = deserializer.Deserialize(NULL, &error);
+ std::unique_ptr<base::Value> root = deserializer.Deserialize(nullptr, &error);
if (!root.get())
return std::unique_ptr<base::DictionaryValue>();
if (!root->IsType(base::Value::Type::DICTIONARY))