Fix code for clang-tidy warnings
After clang-r498229, we got below new warnings:
art/artd/artd.cc:810:42: error: redundant call to 'c_str'
[readability-redundant-string-cstr,-warnings-as-errors]
context = ClassLoaderContext::Create(in_classLoaderContext->c_str());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*in_classLoaderContext->
art/artd/artd.cc:899:35: error: redundant call to 'c_str'
[readability-redundant-string-cstr,-warnings-as-errors]
std::string dex_dir = Dirname(in_dexFile.c_str());
^~~~~~~~~~~~~~~~~~
in_dexFile
art/artd/artd_test.cc:75:42: error: using decl 'GetDexoptStatusResult' is unused
[misc-unused-using-decls,-warnings-as-errors]
using ::aidl::com::android::server::art::GetDexoptStatusResult;
^
art/artd/path_utils_test.cc:31:42: error: using decl 'VdexPath' is unused
[misc-unused-using-decls,-warnings-as-errors]
using ::aidl::com::android::server::art::VdexPath;
^
art/artd/artd_test.cc:394:15: error: parameter 'cancellation_signal' is passed by value
and only copied once; consider moving it to avoid unnecessary copies
[performance-unnecessary-value-param,-warnings-as-errors]
cancellation_signal);
^
std::move( )
Bug: 285008138
Test: build with WITH_TIDY=1
Change-Id: Id17bfea4dc78175aec3b1328e916f8c574e61a8c
diff --git a/artd/artd.cc b/artd/artd.cc
index 5d65b4f..afed965 100644
--- a/artd/artd.cc
+++ b/artd/artd.cc
@@ -807,7 +807,7 @@
std::unique_ptr<ClassLoaderContext> context = nullptr;
if (in_classLoaderContext.has_value()) {
- context = ClassLoaderContext::Create(in_classLoaderContext->c_str());
+ context = ClassLoaderContext::Create(in_classLoaderContext.value());
if (context == nullptr) {
return Fatal(
ART_FORMAT("Class loader context '{}' is invalid", in_classLoaderContext.value()));
@@ -896,7 +896,7 @@
std::vector<std::unique_ptr<File>> context_files;
if (context != nullptr) {
std::vector<std::string> flattened_context = context->FlattenDexPaths();
- std::string dex_dir = Dirname(in_dexFile.c_str());
+ std::string dex_dir = Dirname(in_dexFile);
std::vector<int> context_fds;
for (const std::string& context_element : flattened_context) {
std::string context_path = std::filesystem::path(dex_dir).append(context_element);
diff --git a/artd/artd_test.cc b/artd/artd_test.cc
index b61b11a..44ddae9 100644
--- a/artd/artd_test.cc
+++ b/artd/artd_test.cc
@@ -72,7 +72,6 @@
using ::aidl::com::android::server::art::DexoptOptions;
using ::aidl::com::android::server::art::FileVisibility;
using ::aidl::com::android::server::art::FsPermission;
-using ::aidl::com::android::server::art::GetDexoptStatusResult;
using ::aidl::com::android::server::art::IArtdCancellationSignal;
using ::aidl::com::android::server::art::OutputArtifacts;
using ::aidl::com::android::server::art::OutputProfile;
@@ -392,7 +391,7 @@
std::shared_ptr<IArtdCancellationSignal> cancellation_signal = nullptr) {
RunDexopt(Property(&ndk::ScopedAStatus::getExceptionCode, expected_status),
std::move(aidl_return_matcher),
- cancellation_signal);
+ std::move(cancellation_signal));
}
void RunDexopt(Matcher<ndk::ScopedAStatus> status_matcher,
diff --git a/artd/path_utils_test.cc b/artd/path_utils_test.cc
index b0cc827..77652f0 100644
--- a/artd/path_utils_test.cc
+++ b/artd/path_utils_test.cc
@@ -28,7 +28,6 @@
using ::aidl::com::android::server::art::ArtifactsPath;
using ::aidl::com::android::server::art::DexMetadataPath;
using ::aidl::com::android::server::art::ProfilePath;
-using ::aidl::com::android::server::art::VdexPath;
using ::android::base::testing::HasError;
using ::android::base::testing::HasValue;
using ::android::base::testing::WithMessage;