Fix google-explicit-constructor warnings in system/nvram.
Declare explicit conversion constructors.
Bug: 28341362
Change-Id: I7c9f50c5c9d1e70a8b87a8179a863f07b04b89cd
Test: build with clang-tidy
diff --git a/messages/include/nvram/messages/io.h b/messages/include/nvram/messages/io.h
index 08c1091..3957015 100644
--- a/messages/include/nvram/messages/io.h
+++ b/messages/include/nvram/messages/io.h
@@ -201,7 +201,7 @@
// Construct a |BlobOutputStreamBuffer| that stores all written data to
// |blob|, which will get resized as necessary. Note that |blob| must remain
// valid for the life time of the |BlobOutputStreamBuffer| object.
- BlobOutputStreamBuffer(Blob* blob);
+ explicit BlobOutputStreamBuffer(Blob* blob);
~BlobOutputStreamBuffer() override = default;
// Truncate the blob to match the current output size.
diff --git a/messages/include/nvram/messages/optional.h b/messages/include/nvram/messages/optional.h
index 2860e3e..01a49a6 100644
--- a/messages/include/nvram/messages/optional.h
+++ b/messages/include/nvram/messages/optional.h
@@ -24,7 +24,7 @@
template <typename ValueType> class Optional {
public:
Optional() = default;
- Optional(ValueType value) : value_(value), valid_(true) {}
+ explicit Optional(ValueType value) : value_(value), valid_(true) {}
bool valid() const { return valid_; }
const ValueType& value() const { return value_; }
diff --git a/messages/include/nvram/messages/proto.hpp b/messages/include/nvram/messages/proto.hpp
index aabeb8c..3254583 100644
--- a/messages/include/nvram/messages/proto.hpp
+++ b/messages/include/nvram/messages/proto.hpp
@@ -387,7 +387,7 @@
template <typename StructType>
class MessageEncoder : public MessageEncoderBase {
public:
- MessageEncoder(const StructType& object)
+ explicit MessageEncoder(const StructType& object)
: MessageEncoderBase(&object,
StructDescriptor<StructType>::kDescriptors,
StructDescriptor<StructType>::kNumDescriptors) {}
@@ -404,7 +404,7 @@
template <typename StructType>
class MessageDecoder : public MessageDecoderBase {
public:
- MessageDecoder(StructType& object)
+ explicit MessageDecoder(StructType& object)
: MessageDecoderBase(&object,
StructDescriptor<StructType>::kDescriptors,
StructDescriptor<StructType>::kNumDescriptors) {}
diff --git a/messages/include/nvram/messages/struct.h b/messages/include/nvram/messages/struct.h
index 13932fc..589666f 100644
--- a/messages/include/nvram/messages/struct.h
+++ b/messages/include/nvram/messages/struct.h
@@ -249,7 +249,7 @@
using List = FieldSpecList<FieldSpec, Tail...>;
using TailList = FieldSpecList<Tail...>;
- constexpr FieldSpecList(FieldSpec field_spec, Tail... tail)
+ constexpr explicit FieldSpecList(FieldSpec field_spec, Tail... tail)
: kFieldSpec(field_spec), kTail(tail...) {}
template <size_t index>