Skip to content

Commit

Permalink
clang-tidy modernize-(use-nullptr|raw-string-literal) components/driv…
Browse files Browse the repository at this point in the history
…e/*.

Continue modernization of the drive code, using clang-tidy. This
change replaces NULL with nullptr and strings like
"embedded \"quotes\"" with R"(embedded "quotes")".

Steps:

$ autoninja -C out/Default chrome
$ tools/clang/scripts/generate_compdb.py -p \
  out/Default > compile_commands.json
$ cd out/Default/
$ /usr/local/google/code/llvm/tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
-p ../.. \
-clang-tidy-binary /usr/local/google/code/build/bin/clang-tidy \
-clang-apply-replacements-binary /usr/local/google/code/build/bin/clang-apply-replacements \
-checks=-*,modernize-use-nullptr,modernize-raw-string-literal \
-header-filter= \
-fix components/drive

No logic changes. No new tests.

Bug: 841659
Change-Id: I0ff0f09d3089aa4c72da7d39ef9698140f4a26aa
Reviewed-on: https://chromium-review.googlesource.com/1077107
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562710}
  • Loading branch information
Stuart Langley authored and Commit Bot committed May 30, 2018
1 parent 61c4b64 commit fda065f
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion components/drive/about_resource_loader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AboutResourceLoaderTest : public testing::Test {

cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.GetPath(),
base::ThreadTaskRunnerHandle::Get().get(),
NULL /* free_disk_space_getter */));
nullptr /* free_disk_space_getter */));
ASSERT_TRUE(cache_->Initialize());

metadata_.reset(
Expand Down
2 changes: 1 addition & 1 deletion components/drive/change_list_loader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ChangeListLoaderTest : public testing::Test {

cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.GetPath(),
base::ThreadTaskRunnerHandle::Get().get(),
NULL /* free_disk_space_getter */));
nullptr /* free_disk_space_getter */));
ASSERT_TRUE(cache_->Initialize());

metadata_.reset(new ResourceMetadata(
Expand Down
2 changes: 1 addition & 1 deletion components/drive/directory_loader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DirectoryLoaderTest : public testing::Test {

cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.GetPath(),
base::ThreadTaskRunnerHandle::Get().get(),
NULL /* free_disk_space_getter */));
nullptr /* free_disk_space_getter */));
ASSERT_TRUE(cache_->Initialize());

metadata_.reset(new ResourceMetadata(
Expand Down
2 changes: 1 addition & 1 deletion components/drive/file_system_core_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool CreateGDocFile(const base::FilePath& file_path,
const GURL& url,
const std::string& resource_id) {
std::string content =
base::StringPrintf("{\"url\": \"%s\", \"resource_id\": \"%s\"}",
base::StringPrintf(R"({"url": "%s", "resource_id": "%s"})",
url.spec().c_str(), resource_id.c_str());
return base::WriteFile(file_path, content.data(), content.size()) ==
static_cast<int>(content.size());
Expand Down
4 changes: 2 additions & 2 deletions components/drive/file_system_core_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class FileSystemUtilTest : public testing::Test {

TEST_F(FileSystemUtilTest, EscapeUnescapeCacheFileName) {
const std::string kUnescapedFileName(
"tmp:`~!@#$%^&*()-_=+[{|]}\\\\;\',<.>/?");
R"(tmp:`~!@#$%^&*()-_=+[{|]}\\;',<.>/?)");
const std::string kEscapedFileName(
"tmp:`~!@#$%25^&*()-_=+[{|]}\\\\;\',<%2E>%2F?");
R"(tmp:`~!@#$%25^&*()-_=+[{|]}\\;',<%2E>%2F?)");
EXPECT_EQ(kEscapedFileName, EscapeCacheFileName(kUnescapedFileName));
EXPECT_EQ(kUnescapedFileName, UnescapeCacheFileName(kEscapedFileName));
}
Expand Down
6 changes: 2 additions & 4 deletions components/drive/search_metadata_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,8 @@ TEST_F(SearchMetadataTest,
// \xE3\x80\x80 is ideographic space.
SearchMetadata(
base::ThreadTaskRunnerHandle::Get(), resource_metadata_.get(),
"Directory\xE3\x80\x80"
"1",
base::Bind(&MatchesType, SEARCH_METADATA_ALL), kDefaultAtMostNumMatches,
MetadataSearchOrder::LAST_ACCESSED,
R"(Directory 1)", base::Bind(&MatchesType, SEARCH_METADATA_ALL),
kDefaultAtMostNumMatches, MetadataSearchOrder::LAST_ACCESSED,
google_apis::test_util::CreateCopyResultCallback(&error, &result));

base::RunLoop().RunUntilIdle();
Expand Down
2 changes: 1 addition & 1 deletion components/drive/start_page_token_loader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StartPageTokenLoaderTest : public testing::Test {

cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.GetPath(),
base::ThreadTaskRunnerHandle::Get().get(),
NULL /* free_disk_space_getter */));
nullptr /* free_disk_space_getter */));
ASSERT_TRUE(cache_->Initialize());

metadata_.reset(
Expand Down
2 changes: 1 addition & 1 deletion components/drive/sync_client_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class SyncClientTest : public testing::Test {

cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.GetPath(),
base::ThreadTaskRunnerHandle::Get().get(),
NULL /* free_disk_space_getter */));
nullptr /* free_disk_space_getter */));
ASSERT_TRUE(cache_->Initialize());

metadata_.reset(new internal::ResourceMetadata(
Expand Down
2 changes: 1 addition & 1 deletion components/drive/team_drive_list_loader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TeamDriveListLoaderTest : public testing::Test {

cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.GetPath(),
base::ThreadTaskRunnerHandle::Get().get(),
NULL /* free_disk_space_getter */));
nullptr /* free_disk_space_getter */));
ASSERT_TRUE(cache_->Initialize());

metadata_.reset(
Expand Down

0 comments on commit fda065f

Please sign in to comment.