Don't use scoped_ptr, use std::move for proto
scoped_ptr is being removed from protobuf, use std::unique_ptr
instead.
Protos support std::move now, which trips the clang-tidy
modernize-pass-by-value check. Change it to pass by value with
std::move.
Also fix a string in a test that has changed.
Bug: 117607748
Test: m checkbuild
Change-Id: Ib0c953a691903b75766524200d43a6ed2c7582c0
Merged-In: Ib0c953a691903b75766524200d43a6ed2c7582c0
diff --git a/apexd/apex_manifest.cpp b/apexd/apex_manifest.cpp
index 46ab4d8..bad5647 100644
--- a/apexd/apex_manifest.cpp
+++ b/apexd/apex_manifest.cpp
@@ -26,7 +26,6 @@
using android::base::Error;
using android::base::Result;
using google::protobuf::DescriptorPool;
-using google::protobuf::scoped_ptr;
using google::protobuf::util::NewTypeResolverForDescriptorPool;
using google::protobuf::util::TypeResolver;
@@ -47,7 +46,7 @@
// as and when the android tree gets updated
Result<void> JsonToApexManifestMessage(const std::string& content,
ApexManifest* apex_manifest) {
- scoped_ptr<TypeResolver> resolver(NewTypeResolverForDescriptorPool(
+ std::unique_ptr<TypeResolver> resolver(NewTypeResolverForDescriptorPool(
kTypeUrlPrefix, DescriptorPool::generated_pool()));
std::string binary;
auto parse_status = JsonToBinaryString(
diff --git a/apexd/apex_manifest_test.cpp b/apexd/apex_manifest_test.cpp
index 3d7550c..44528fa 100644
--- a/apexd/apex_manifest_test.cpp
+++ b/apexd/apex_manifest_test.cpp
@@ -59,7 +59,7 @@
ASSERT_FALSE(apex_manifest);
EXPECT_EQ(apex_manifest.error().message(),
std::string("Failed to parse APEX Manifest JSON config: "
- "version: invalid value \"a\" for type TYPE_INT64"))
+ "(version): invalid value \"a\" for type TYPE_INT64"))
<< apex_manifest.error();
}
diff --git a/apexd/apexd_session.cpp b/apexd/apexd_session.cpp
index 0d05d9d..979b27c 100644
--- a/apexd/apexd_session.cpp
+++ b/apexd/apexd_session.cpp
@@ -28,6 +28,7 @@
#include <filesystem>
#include <fstream>
#include <optional>
+#include <utility>
using android::base::Error;
using android::base::Result;
@@ -79,7 +80,7 @@
} // namespace
-ApexSession::ApexSession(const SessionState& state) : state_(state) {}
+ApexSession::ApexSession(SessionState state) : state_(std::move(state)) {}
Result<ApexSession> ApexSession::CreateSession(int session_id) {
SessionState state;
diff --git a/apexd/apexd_session.h b/apexd/apexd_session.h
index e060cf7..142aa15 100644
--- a/apexd/apexd_session.h
+++ b/apexd/apexd_session.h
@@ -53,7 +53,7 @@
android::base::Result<void> DeleteSession() const;
private:
- ApexSession(const ::apex::proto::SessionState& state);
+ ApexSession(::apex::proto::SessionState state);
::apex::proto::SessionState state_;
static android::base::Result<ApexSession> GetSessionFromFile(