summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Bray <ncbray@google.com>2019-01-18 14:44:19 -0800
committerNick Bray <ncbray@google.com>2019-02-07 11:08:44 -0800
commit3b12e5e65bd82c39a600def425cd21783a361561 (patch)
tree1a7619f430102f611288e07dd2a70985579b1552
parent23e024aec04a642c1dbf7f022467c8d687f11f86 (diff)
downloadkeymaster-3b12e5e65bd82c39a600def425cd21783a361561.tar.gz
Fix issue where hiding copy constructor deletes move constructor.android-q-preview-1android-o-mr1-iot-release-1.0.10
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
-rw-r--r--include/keymaster/android_keymaster_messages.h5
-rw-r--r--include/keymaster/serializable.h9
2 files changed, 7 insertions, 7 deletions
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 @@ inline int32_t MessageVersion(uint8_t major_ver, uint8_t minor_ver, uint8_t /* s
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 KeymasterMessage : public Serializable {
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 @@ class Serializable {
*/
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;
};
/*