Fix issue where hiding copy constructor deletes move constructor.
Hiding the copy constructor for Serializable meant the default move
constructor was implicitly deleted. A strict reading of the spec would
mean that subclasses should not be able to default their move
constructors.
This issue was revealed by -Wdefaulted-function-deleted.
Bug: 123093254
Change-Id: I3cb4917dd37ae9f72d673993c9249e29c36f40e6
diff --git a/include/keymaster/android_keymaster_messages.h b/include/keymaster/android_keymaster_messages.h
index 5adf4c6..002a3ac 100644
--- a/include/keymaster/android_keymaster_messages.h
+++ b/include/keymaster/android_keymaster_messages.h
@@ -103,7 +103,7 @@
struct KeymasterMessage : public Serializable {
explicit KeymasterMessage(int32_t ver) : message_version(ver) { assert(ver >= 0); }
- KeymasterMessage(KeymasterMessage&& other) : message_version(move(other.message_version)) {}
+
uint32_t message_version;
};
@@ -116,9 +116,6 @@
struct KeymasterResponse : public KeymasterMessage {
explicit KeymasterResponse(int32_t ver)
: KeymasterMessage(ver), error(KM_ERROR_UNKNOWN_ERROR) {}
- KeymasterResponse(KeymasterResponse&& other)
- : KeymasterMessage(move(other)), error(move(other.error)) {}
- KeymasterResponse& operator=(KeymasterResponse&&) = default;
size_t SerializedSize() const override;
uint8_t* Serialize(uint8_t* buf, const uint8_t* end) const override;
diff --git a/include/keymaster/serializable.h b/include/keymaster/serializable.h
index f182645..9f69f44 100644
--- a/include/keymaster/serializable.h
+++ b/include/keymaster/serializable.h
@@ -52,10 +52,13 @@
*/
virtual bool Deserialize(const uint8_t** buf_ptr, const uint8_t* end) = 0;
- private:
// Disallow copying and assignment.
- Serializable(const Serializable&);
- void operator=(const Serializable&);
+ Serializable(const Serializable&) = delete;
+ Serializable& operator=(const Serializable&) = delete;
+
+ // Move only.
+ Serializable(Serializable&&) = default;
+ Serializable& operator=(Serializable&&) = default;
};
/*